我有一个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