设置宽度 textview 在 LinearLayout
我使用标题 Listview. ListView 标题有三列。 告诉我 a,b, c. 我用二 LinearLayouts 用于开发标题 ListView, 如下所示:
现在我想修复列宽度 a, b, c 分别。 如何设置这些列的宽度 ? 再一次,是一个很好的做法 LinearLayout ? 请指教。
xml version="1.0" encoding="utf-8"?
<linearlayout android:layout_height="40dip" android:layout_width="fill_parent" android:padding="0dip" xmlns:android="[url=http://schemas.android.com/apk/res/android">]http://schemas.android.com/apk ... gt%3B[/url]
<linearlayout android:background="#1e90ff" android:layout_height="40dip" android:layout_weight="1" android:layout_width="0dip" android:orientation="horizontal" android:padding="5dip">
<textview android:gravity="center_vertical" android:id="@+id/a" android:layout_height="fill_parent" android:layout_weight="1" android:layout_width="fill_parent" android:text="@string/a" android:textcolor="#000000"></textview>
<textview android:gravity="center_vertical" android:id="@+id/b" android:layout_height="fill_parent" android:layout_weight="1" android:layout_width="fill_parent" android:singleline="true" android:text="@string/b" android:textcolor="#000000"></textview>
<textview android:gravity="center_vertical" android:id="@+id/c" android:layout_height="fill_parent" android:layout_weight="1" android:layout_width="fill_parent" android:singleline="true" android:text="@string/c" android:textcolor="#000000"></textview>
</linearlayout>
</linearlayout>
现在我想修复列宽度 a, b, c 分别。 如何设置这些列的宽度 ? 再一次,是一个很好的做法 LinearLayout ? 请指教。
没有找到相关结果
已邀请:
4 个回复
奔跑吧少年
赞同来自:
或者您希望它们占用屏幕百分比,更改 layout_weight
在 android 另一个内部的所有元素的重量 /例如,这里的线性布局/ 它将被折叠在一起,然后使用每个物种的重量来确定所需的空间。 I.E. 如果您分别具有2,3,5,b,c,则重量,那么 20% 宽阔,宽 30% 和 c 50% 宽的。
如果需要列,则应考虑使用表布局 /
http://developer.android.com/g ... .html
/
詹大官人
赞同来自:
莫问
赞同来自:
用于动态尺寸安装
小明明
赞同来自:
这是适配器的代码 ListView: