如何申请row_span到TableLayout?
我要让类似这样的形象的东西,但我不知道该怎么做。
是什么力量让这样的事情的正确方法?
如何申请row_span到TableLayout?
我要让类似这样的形象的东西,但我不知道该怎么做。
是什么力量让这样的事情的正确方法?
TableLayout
不支持行跨度,仅列跨越。 GridLayout
支持行和列跨度:
(图片来自http://android-developers.blogspot.com/2011/11/new-layout-widgets-space-and-gridlayout.html )
小作弊(也许相当复杂的代码,只适用于简单的设计):
做一个TableLayout
。 换个TableLayout
的第一列,要在第二列的行跨度一个视图中。 这种内在TableLayout
可以有许多TableRows
为你哗哗另一种观点跨越。
下面的代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/activity_horizontal_margin"
tools:context=".MainActivity">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3">
<TableLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/holo_blue_dark">
<TextView
android:text="Row 1"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/holo_blue_light">
<TextView
android:text="Row 2"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/holo_blue_bright">
<TextView
android:text="Row 3"/>
</TableRow>
</TableLayout>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5"
android:text="Second column, rowspan 3"
android:background="@android:color/holo_purple"
android:gravity="center"/>
</TableRow>
</TableLayout>
</LinearLayout>
于是,涂总结:
TableLayout:第一列(TableLayout用,因为我们希望尽可能多的TableRows),第二列(即会占用所有的行空间元素)。
你有没有使用“ 机器人:layout_span”它可以用来跨越行。 你无法通过Ctrl +空格键得到它,你需要手动输入。