![](/img/trans.png)
[英]what is the equivalenet tag for ROWSPAN in table layout in android
[英]android table layout rowspan
我想構建以下布局但它不起作用。
alt text http://toms-toy.de/rowspan.gif
<LinearLayout android:orientation="horizontal"...>
<ImageView ...></ImageView>
<TableLayout ...>
<TableRow..>
<ImageView ...></ImageView>
<ImageView ...></ImageView>
<ImageView ...></ImageView>
</TableRow>
<TableRow..>
<ImageView ...></ImageView>
<ImageView ...></ImageView>
<ImageView ...></ImageView>
</TableRow>
</TableLayout>
<ImageView ...></ImageView>
</LinearLayout>
我把它放在一起非常快,試試這個:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:layout_width="50dip" android:layout_height="100dip" android:background="#cc0000"/>
<TableLayout android:layout_width="wrap_content" android:layout_height="wrap_content">
<TableRow>
<ImageView android:layout_width="50dip" android:layout_height="50dip" android:background="#aaaa00"/>
<ImageView android:layout_width="50dip" android:layout_height="50dip" android:background="#00aa00"/>
<ImageView android:layout_width="50dip" android:layout_height="50dip" android:background="#aaaa00"/>
</TableRow>
<TableRow>
<ImageView android:layout_width="50dip" android:layout_height="50dip" android:background="#00aa00"/>
<ImageView android:layout_width="50dip" android:layout_height="50dip" android:background="#aaaa00"/>
<ImageView android:layout_width="50dip" android:layout_height="50dip" android:background="#00aa00"/>
</TableRow>
</TableLayout>
<ImageView android:layout_width="50dip" android:layout_height="100dip" android:background="#cc0000"/>
</LinearLayout>
嘗試這個:
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow>
<TextView android:text="1-2, 1;\t" android:layout_gravity="center" />
<TableLayout>
<TableRow>
<TextView android:text="1, 2;\t" android:layout_gravity="center" />
</TableRow>
<TableRow>
<TextView android:text="2, 2;\t" android:layout_gravity="center" />
</TableRow>
</TableLayout>
</TableRow>
</TableLayout>
以下代碼的輸出
默認情況下,android沒有任何名為rowspan的屬性,但下面的代碼工作正常並創建了行跨度。
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TableRow>
<TextView
android:text="Hello"
android:textSize="30dp"
/>
<TextView
android:text="Hello World"
android:textSize="30dp"
android:background="@drawable/border"
/>
<Button android:text="Click me"
android:textSize="30dp"/>
</TableRow>
<TableRow>
<TextView
android:text="Hello"
android:textSize="30dp"
/>
<Button android:text="Click"
android:textSize="30dp"
android:layout_column="2"/>
</TableRow>
<TableRow>
<TextView
android:text="Hello"
android:textSize="30dp"
/>
<TextView
android:text="Hello"
android:textSize="30dp"
/>
<Button android:text="Click me"
android:textSize="30dp"/>
</TableRow>
<TableRow>
<TableLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_span="2">
<TableRow>
<Button android:text="1"/>
<Button android:text="2"/>
</TableRow>
<TableRow>
<Button android:text="3"/>
<Button android:text="4"/>
</TableRow>
</TableLayout>
<Button
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:text="Enter"
android:background="#ff0099"/>
</TableRow>
</TableLayout>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.