textview在android中没有“fill_parent”?

时间:2011-08-17 15:34:04

标签: android android-layout

我需要在列表项旁边显示一个id。即使我将id textview height设置为fill_parent,它似乎也没有任何效果。这是我的完整代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android: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>

1 个答案:

答案 0 :(得分:2)

我可以通过以下教程解决问题: http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html

对Android UI中的初学者非常有用。