Android Layout Design For Normal Screen Sizes
I am a hobbiest app developer and I feel I have a good grasp on android basics but the main thing that I struggle at is app design. I understand how to develop for different screen
Solution 1:
Try adding another layout for side buttons to group them together, and then center that layout:
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/RelativeLayout1"android:layout_width="match_parent"android:layout_height="match_parent"android:columnCount="4"android:orientation="vertical"android:layout_alignParentTop="true"android:layout_alignParentLeft="true"android:layout_alignParentStart="true"><Buttonandroid:id="@+id/Button1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:layout_centerVertical="true"android:background="@drawable/i1"android:text="Button" /><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/RelativeLayout2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"><Buttonandroid:id="@+id/button1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="false"android:layout_alignParentTop="true"android:background="@drawable/i2"android:layout_alignParentLeft="true"/><Buttonandroid:id="@+id/button2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/i3"android:layout_below="@+id/button1"android:layout_alignParentLeft="true"/><Buttonandroid:id="@+id/button3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/i4"android:layout_below="@+id/button4"android:layout_toRightOf="@+id/button2"/><Buttonandroid:id="@+id/button4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/i5"android:layout_toRightOf="@+id/button2"android:layout_alignParentTop="true"/></RelativeLayout></RelativeLayout>
Solution 2:
You need to create different images for each of the screen resolutions and put them into the respective drawable
folder drawable--hdpi
, drawable-mdpi
, drawable-xhdpi
, etc. Also be sure that you are using dp
in your xml
file, which it appears you are. Just be sure you always do so.
Designing for the different screens can be tricky because you have to essentially create the same image 4 or 5 times.
Also, make sure you are testing on actual handsets, because the emulator doesn't always give you an accurate layout.
Post a Comment for "Android Layout Design For Normal Screen Sizes"