如何在
Android ListView中创建列?我有这个列表项布局xml:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"> <TextView android:layout_weight=".3" android:layout_width="wrap_content" android:layout_height="fill_parent" android:id="@+id/hour" android:gravity="center" /> <ImageView android:id="@+id/symbol" android:scaleType="fitCenter" android:layout_gravity="center_horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight=".5" /> <TextView android:layout_weight=".8" android:layout_width="wrap_content" android:layout_height="fill_parent" android:id="@+id/temperature" android:gravity="center" /> <TextView android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="fill_parent" android:id="@+id/percipitation" android:gravity="center" /> <TextView android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="fill_parent" android:id="@+id/wind_speed" android:gravity="center" /> <TextView android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="fill_parent" android:id="@+id/wind_direction" android:gravity="center" /> </LinearLayout>
问题是f.ex. wind_direction从“4”变为“300”,然后列不对齐.
The problem http://img185.imageshack.us/img185/2812/deviceo.png
谁可以用固定宽度的列制作并使用与设备无关的整个宽度?
解决方法
考虑使用TableLayout而不是ListView.这被设计为具有行和列.见
Hello TableLayout.
要以编程方式添加行,可以使TableRow膨胀并在TableLayout上调用addView.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。