我设法使用 TableLayout
设计布局。 android:layout_span
在这方面帮助了我。
问题是我需要在 Column1 和 Column2 之间留一些空隙。无论哪种方式 Padding/Margin
我不喜欢程序来完成这项任务。一定有一种简单的方法可以做到这一点。
可以用xml设置吗?
更新: 我试图设置列子的填充它没有均匀对齐列。
最佳答案
尝试将 android:layout_marginRight="8dp"
列中的 View 添加到您希望布局 XML 中每一行的间隙所在位置的左侧。它对我有用。
更好的是,您可以将填充尺寸放在 values/dimens.xml 文件中并从那里引用边距。
例如:
值/维度.xml
<resources>
<dimen name="column_1_right_margin">8dp</dimen>
</resources>
布局/表格.xml
<TableLayout
... layout params>
<TableRow>
<TextView
... layout params
android:layout_marginRight="@dimen/column_1_right_margin" />
<TextView
... layout params />
</TableRow>
<TableRow>
<TextView
... layout params
android:layout_marginRight="@dimen/column_1_right_margin" />
<TextView
... layout params />
</TableRow>
</TableLayout>
要进一步清除它并停止代码重复,您可以为第 1 列创建一个样式,然后您所要做的就是为第一列中的每个 View
应用该样式。 See here for more info .
关于android - 如何在xml中设置android表格布局列填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11435276/