我有一個LinearLayout中的textView,它顯示的文本不總是居中,即使我使用gravity =「center」屬性。此外,我已經設置了layou_width與「match_parent。TextView重力屬性不起作用
這TextView的是在的LinearLayout這在LinearLayout中這是在考慮到父母的LinearLayout。
我TextView的是在ListView和代表結束該項目生產線。
我的適配器使用ViewHolder模式。
在這裏,我真不明白,爲什麼有時文本中心和有時它的左側。
這裏2個截圖我的觀點的wi TH不同的狀態,你可以看到對齊問題:
我想吃點什麼: 這只是對文字現在或者是時候了顯示在這個地方,我想只顯示在中心這個文本,有時它顯示在左邊,你可以看到上面的截圖。
ListView的佈局:
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/dialogTitle"
android:listSelector="@drawable/listitem_selector"
tools:listitem="@layout/item_customer_in_queue">
</ListView>
項目佈局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/item_in_queue_list"
android:layout_width="match_parent"
android:layout_height="@dimen/in_queue_item_height"
android:minHeight="@dimen/in_queue_item_height"
android:background="@color/bckg"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.95">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent">
<ImageView.../>
<ImageView.../>
<ImageView.../>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent">
<ImageView.../>
<ImageView.../>
</RelativeLayout>
<TextView.../>
<TextView.../>
<TextView.../>
<LinearLayout <=here my LinearLayout of my issue
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="fill_parent"
android:layout_height="20dp"
android:layout_weight="0.1"
android:layout_gravity="bottom"/>
<TextView
android:id="@+id/list_dueTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" <=here my issue
android:text="due"
android:layout_weight="0.8"
android:textColor="@color/dark_grey"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</LinearLayout>
<ProgressBar.../>
</LinearLayout>
U可以只顯示烏爾問題? – Android 2014-12-05 12:12:30
'layout_gravity =「bottom」'對於父'LinearLayout''orientation =「vertical」不起作用'' – kId 2014-12-05 12:12:38
'你試過了layout_gravity =「center」? – Umair 2014-12-05 12:14:53