Table layout span across multiple rows

不羁岁月 提交于 2019-12-24 23:48:03

问题


I have this layout and I would like the image to span across 2 rows, so that the 2 buttons are both located at its left. I can't figure how to do that and I have not yet found the equivalent of android:layout_span for rows.

Also my buttons are supposed to display a png as backgroundbut they are displayed much bigger than the expected 56Px per 56Px...

can anyone help me please ?

<TableLayout 
android:id="@+id/TableLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content" 
android:stretchColumns="0">

  <TableRow
  android:id="@+id/TableRow01"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">

  <Button android:id="@+id/btn_www"
  android:background="@drawable/iconeweb"
  android:layout_width="56px"
  android:layout_height="56px"/>

  <ImageView android:id="@+id/image_gpe"
  android:layout_width="200dip"
  android:layout_height="175dip"/>
  </TableRow>

<TableRow
 android:id="@+id/TableRow02"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content">

 <Button android:id="@+id/btn_vid"
  android:background="@drawable/iconecam"
  android:layout_width="56px"
  android:layout_height="56px"/>
</TableRow>
</TableLayout>

回答1:


Use RelativeLayout, use dp instead of px.
Adjust the code below to your requirements:

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <Button
        android:id="@+id/btn_www"
        android:background="@drawable/iconeweb"
        android:layout_width="56dp"
        android:layout_height="56dp" />

    <Button
        android:id="@+id/btn_vid"
        android:background="@drawable/iconecam"
        android:layout_below="@id/btn_www"
        android:layout_width="56dp"
        android:layout_height="56dp" />

    <ImageView
        android:id="@+id/image_gpe"
        android:layout_alignParentRight="true"
        android:layout_toRightOf="@id/btn_www"
        android:layout_width="200dip"
        android:layout_height="175dip" />

</RelativeLayout>


来源:https://stackoverflow.com/questions/6177729/table-layout-span-across-multiple-rows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!