0
我有一個顯示項目列表的頁面。列表中的每一行都有三列,出於某種原因,列表中的項目沒有正確對齊。 下面是我的代碼:Android:CustomListAdapter列未正確對齊
自定義適配器:
<TextView
android:id="@+id/tvCategoryName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:layout_weight="0.90"
android:textAlignment="textStart"/>
<TextView
android:id="@+id/tvWeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Weight"
android:layout_weight="0.05"
android:textAlignment="center"/>
<TextView
android:id="@+id/tvAverage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Average"
android:layout_weight="0.05"
android:textAlignment="center"/>
</LinearLayout>
我想Categories
,Weight
和Average
所有三列是以與centered
文本對齊的格式顯示在一個漂亮的表格中。
當「類別名稱」太長或太短時,仍不起作用 –
是的,如果您使用的是layout_weight,則應該將layout_width設置爲0dp –
工作正常!非常感謝你 :) –