I’m new to Android and am trying to understand how to get a particular layout right? Can anyone explain Which layout does Venmo use for their first screen of the Android app (left most image at the following link: http://30.media.tumblr.com/tumblr_lak5yachMv1qcl8xuo1_500.png)
I tried to create a layout similar to that for learning purposes but can’t get it right. Here is my sample layout code:
<?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>
What I’m trying to figure out:
- How to scale an ImageButton to 50% of the screen width and height
- how to have a flexible height of the ImageButton
- How to get rid of the margin or padding on the edges such that the ImageButton’s stick to the wall and each other.
- Is a TableLayout a good approach for this layout?
- Are there any guidelines for creating images for ImageButton?
Thank you for your help.
I’m the developer of the Venmo Android app.
The other answer suggests using a GridLayout which might work better, but the Venmo app is actually using a table layout.
Here are answers to each individual question…
Here’s some sample code of how the Venmo app creates the grid:
Keep in mind that if the screen is ever physically smaller than your ImageButton’s drawable you’re going to run into issues. Also, if you do this you’ll definitely want to make a separate layout for landscape orientation.