Android:CustomListAdapter列未正确对齐

时间:2016-11-13 02:27:44

标签: android xml listadapter

我有一个显示项目列表的页面。列表中的每一行都有三列,由于某种原因,列表中的项目未正确对齐。 以下是我的代码:

自定义适配器:     

return value

下面是它如何显示的屏幕截图: enter image description here

我希望 <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> CategoriesWeight所有三列都显示在一个漂亮的表格中,格式为Average文字对齐。

1 个答案:

答案 0 :(得分:1)

更新:将hw.mainKeys=yes hw.keyboard=yes 设置为所有TextView。否则layout_weight将无法正常工作。对于垂直方向的父布局集layout_width="0dp"

也许layout_height="0"太少,尝试使用更大的值,例如对于tvWeight和tvAverage为0.2,对于tvCategoryName为0.6。