Android布局帮助(类似于venmo)
我是Android新手,正在努力理解如何正确地进行特定的布局?有人能解释一下Venmo在Android应用程序的第一个屏幕上使用的布局吗(最左边的图片在下面的链接:) 我试图创建一个类似的布局,用于学习目的,但不能得到它的权利。以下是我的布局代码示例:Android布局帮助(类似于venmo),android,layout,tablelayout,Android,Layout,Tablelayout,我是Android新手,正在努力理解如何正确地进行特定的布局?有人能解释一下Venmo在Android应用程序的第一个屏幕上使用的布局吗(最左边的图片在下面的链接:) 我试图创建一个类似的布局,用于学习目的,但不能得到它的权利。以下是我的布局代码示例: <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http``://schemas.android.com/apk/res/android" a
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http``://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:id="@+id/tableLayout1"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="#fff"
android:scrollbars="none">
<TableRow
android:layout_height="wrap_content"
android:id="@+id/tableRow1">
<ImageButton
android:layout_height="wrap_content"
android:id="@+id/imageButton5"
android:background="@drawable/icon"
android:layout_width="wrap_content"
android:layout_weight="1">
</ImageButton>
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:id="@+id/tableRow2">
<TextView
android:text="TextView"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_weight="1">
</TextView>
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_height="wrap_content"
android:layout_margin="0dip"
android:padding="0px"
android:background="#ff6600">
<ImageButton
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/imageButton1"
android:background="@drawable/icon"
android:gravity="left"
android:layout_weight="1">
</ImageButton>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton2"
android:background="@drawable/icon"
android:gravity="right"
android:layout_weight="1">
</ImageButton>
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_height="wrap_content">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton3"
android:background="@drawable/icon"
android:gravity="left"
android:layout_weight="1">
</ImageButton>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton4"
android:background="@drawable/icon"
android:gravity="right"
android:layout_weight="1">
</ImageButton>
</TableRow>
</TableLayout>
我想弄明白的是:
谢谢你的帮助。改用网格布局,至于边距,有一个属性控制它。如果你只有4幅图像,如果你使用网格布局,它们将适当渲染(你想要的50%s)。gridView教程实际上相当不错。看一看。我是Venmo Android应用程序的开发者 另一个答案建议使用GridLayout,这可能会更好,但Venmo应用程序实际上使用的是表格布局 下面是每个问题的答案
<TableLayout android:layout_width="fill_parent" android:layout_height="fill_parent">
<TableRow android:layout_weight="1">
<ImageButton android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="fill_parent"
android:src="@drawable/top_left"
android:layout_marginRight="2sp"
android:layout_marginBottom="2sp"
android:background="@drawable/button"/>
<ImageButton android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="fill_parent"
android:src="@drawable/top_right"
android:layout_marginBottom="2sp"
android:background="@drawable/button"/>
</TableRow>
<TableRow android:layout_weight="1">
<ImageButton android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="fill_parent"
android:src="@drawable/bottom_left"
android:layout_marginRight="2sp"
android:background="@drawable/button"/>
<ImageButton android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="fill_parent"
android:src="@drawable/bottom_right"
android:background="@drawable/button"/>
</TableRow></TableLayout>
请记住,如果屏幕实际尺寸小于ImageButton的可绘制尺寸,您将遇到问题。此外,如果您这样做,您肯定会希望为横向方向制作一个单独的布局