Reputation: 625
I want to create a layout that appears on all devices as it does on my phone. I have tried to make it work for tablets, but it looks awful.
Here is what it should look like:
But here is how it appears on this tablet emulator:
What can I do to make it appear on all screen sizes like it is on my phone? I am currently using a RelativeLayout. Here is my code:
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout02"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/terranlogo1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:src="@drawable/terranlogo" />
<ImageView
android:id="@+id/protosslogo1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentRight="true"
android:src="@drawable/protosslogo" />
<ImageView
android:id="@+id/zerglogo1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:src="@drawable/zerglogo" />
<CheckBox
android:id="@+id/ck_t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/terranlogo1"
android:layout_centerHorizontal="true" />
<CheckBox
android:id="@+id/ck_p1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/protosslogo1"
android:layout_below="@id/protosslogo1"
android:layout_marginLeft="25dp" />
<CheckBox
android:id="@+id/ck_z1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/zerglogo1"
android:layout_below="@id/zerglogo1"
android:layout_marginLeft="25dp" />
<ImageView
android:id="@+id/terranlogo2"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_below="@id/ck_t1"
android:layout_centerHorizontal="true"
android:src="@drawable/terranlogo" />
<ImageView
android:id="@+id/protosslogo2"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentRight="true"
android:layout_below="@id/ck_p1"
android:src="@drawable/protosslogo" />
<ImageView
android:id="@+id/zerglogo2"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_below="@id/ck_z1"
android:src="@drawable/zerglogo" />
<CheckBox
android:id="@+id/ck_t2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/terranlogo2"
android:layout_centerHorizontal="true" />
<CheckBox
android:id="@+id/ck_p2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/protosslogo1"
android:layout_below="@id/protosslogo2"
android:layout_marginLeft="25dp" />
<CheckBox
android:id="@+id/ck_z2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/zerglogo1"
android:layout_below="@id/zerglogo2"
android:layout_marginLeft="25dp" />
<TextView
android:id="@+id/textView4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/ck_t2"
android:layout_marginRight="18dp"
android:layout_marginTop="17dp"
android:gravity="center_vertical|center_horizontal"
android:text="Choose your opponets race(s) and your race(s)"
android:textSize="30dp" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="Game Length"
android:textSize="15dp" />
<Spinner
android:id="@+id/s_answertime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView1"
android:layout_alignParentLeft="true"
android:layout_below="@id/textView4" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/terranlogo2"
android:layout_alignParentBottom="true"
android:gravity="center_horizontal"
android:text="Mistakes Allowed"
android:textSize="15dp" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Answer Time"
android:textSize="15dp" />
<Spinner
android:id="@+id/s_mistakenumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/s_answertime"
android:layout_alignTop="@+id/s_answertime"
android:layout_toLeftOf="@+id/s_gametime"
android:layout_toRightOf="@+id/s_answertime" />
<Spinner
android:id="@+id/s_gametime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView3"
android:layout_alignLeft="@+id/protosslogo2"
android:layout_alignTop="@+id/s_mistakenumber" />
</RelativeLayout>
All help is appreciated, Lijap.
Upvotes: 0
Views: 352
Reputation: 20090
The spinners are stretched because you set layout_above and layout_below, so they stretch to accomodate both criteria. Remove one of these (probably layout_above) and set a reasonable fixed height for them (75dp?).
Also, your left/right most icon/checkboxes would probably look better with a nice healthy margin_left/right=50dp, to keep them from stretching all the way to the edge of the screen.
Upvotes: 1