Align row texts in a listview
The row of my listview has 3 texts. What I want to do is to align all the rows texts vertically. I tried that using the TableLayout view for the row, and I've set the width for the first and third cell's as a constant. I'm not very happy using constants because of the porting issues. Is it possible to align these texts without in another way? Here is the layout:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/ingredient_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<com.one2snap.littlechef.android.main.ui.views.AmienneTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
androi开发者_JAVA百科d:id="@+id/ingredient_title" />
</LinearLayout>
You can use a LinearLayout and apply a Weight to each Text view. If you give each text a weight of 1, then they will each take a third of the screen equally. If you gave one text a weight of 2 and the others a weight of 1, then the 2 will take half of the screen the other two will use a fourth, etc. See here under LinearLayout for more info.
精彩评论