abh*_*eta 11 android android-layout android-tablelayout
我在设置表行(包含文本视图)的布局参数时遇到一些困难.
我想添加一些列以获得良好的布局.我是动态地做的.(在代码中)
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ok"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="bye"/>
</TableRow>
Run Code Online (Sandbox Code Playgroud)
我希望这两个textviews相应地成为两列和屏幕上的布局.
Bor*_*jev 17
你已经写过的东西实际上应该已经创建了两列,事实是它们可能没有像你期望的那样位于屏幕上 - 列将尽可能地缩小.Android布局中的TableLayout标记有几个属性.其中之一是拉伸柱 - 如果给定所描述的列将被拉伸,以便填充所有指定的宽度.如果你需要全部拉伸均匀使用星号,如果你想要拉伸任何特定列覆盖剩余空间使用其基于1的索引(你可以指定一组索引).看这里:
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="0,1" >
<TableRow android:layout_width="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ok"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="bye" />
</TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud)
顺便说一下,如果你只需要一行,你可以对LinearLayout和orientation ="horizontal"做同样的事情.如果你有几行,请记住你实际上正在处理表 - 列的所有行都将恰好位于另一行之上,最宽的行将决定列的宽度.
| 归档时间: |
|
| 查看次数: |
30726 次 |
| 最近记录: |