textview does not "fill_parent" in android?
I need to display an id next to a list item. Even though I set the id textview height to fill_parent it does not seem to have any effect. Here is my full code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
andr开发者_如何学Gooid:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/bgColor"
>
<TextView
android:id="@+id/DisplayID"
android:layout_width="80px"
android:layout_marginRight="1px"
android:textColor="@color/textColor"
android:background="#ead7a4"
android:padding="12px"
android:gravity="center"
android:layout_height="fill_parent"/>
<TextView
android:id="@+id/DisplayText"
android:layout_width="fill_parent"
android:gravity="right"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/DisplayID"
android:textColor="@color/textColor"
android:background="#ead7a4"
android:padding="12px"/>
<TextView
android:id="@+id/DisplayTextPhonetic"
android:layout_below="@+id/DisplayTextArabic"
android:layout_width="fill_parent"
android:gravity="left"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/DisplayID"
android:textColor="@color/textColor"
android:background="#ead7a4"
android:padding="12px"
android:visibility="gone"
/>
<TextView
android:id="@+id/DisplayTextTrans"
android:layout_below="@+id/DisplayTextPhonetic"
android:layout_width="fill_parent"
android:gravity="left"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/DisplayID"
android:textColor="@color/textColor"
android:background="#ead7a4"
android:padding="12px"
android:visibility="gone"/>
</RelativeLayout>
I was able to solve the problem by following this tutorial: http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html
It is very useful for beginners in Android UI.
精彩评论