Android: how to make two TextViews placed in different lines if there is no enough space in one line
        Posted  
        
            by 
                bluebyte
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by bluebyte
        
        
        
        Published on 2012-04-08T23:17:42Z
        Indexed on 
            2012/04/08
            23:29 UTC
        
        
        Read the original article
        Hit count: 262
        
I'am trying to organize two TextViews to behave like that:

So, if there is enough space for both TextViews in line, android should place them in line.
If there is no enough space, the second TextView must be placed on a next line with right alignment.
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
        <TextView
            android:id="@+id/takeoffCity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/flightItem" />
        <TextView
            android:id="@+id/landingCity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/flightItem" />
    </LinearLayout>
<style name="flightItem" parent="@android:style/TextAppearance">
    <item name="android:textSize">14dip</item>
    <item name="android:textColor">@color/flightItemFont</item>
    <item name="android:scrollHorizontally">true</item>
    <item name="android:textStyle">bold</item>
</style>
        © Stack Overflow or respective owner