TheO
TheO

Reputation: 667

Position two textviews around center. (Right and left aligned)

I have a ListView where each line has two words. I would like the two words to be align around the center with a small gap.

Similar to (some random words...):

 Please    Help
     me    !!
   This    should
    not    be
     so    hard            

Each row in the ListView consists of two TextViews..

Upvotes: 0

Views: 570

Answers (1)

tundundun
tundundun

Reputation: 644

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.4"
        android:gravity="right" />

    <View
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="0.2"
        />

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.4"
        android:gravity="left" />

</LinearLayout>

Upvotes: 2

Related Questions