Reputation: 481
I have designed the following layout http://i61.tinypic.com/33w1oy1.jpg
But it looks like this in any device: http://i60.tinypic.com/zvbxiu.png
Why there is a gap between the inquiry and training buttons.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff" >
<Button
android:id="@+id/bExit"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:text="@string/Exit" />
<Button style="?android:attr/borderlessButtonStyle"
android:id="@+id/bInquiry"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_above="@+id/bContactus "
android:layout_alignParentLeft="true"
android:text="@string/buttonInquiry" />
<Button style="?android:attr/borderlessButtonStyle"
android:id="@+id/bContactus "
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_above="@+id/bExit"
android:layout_alignParentLeft="true"
android:text="@string/buttonContactUs"
android:background="#f7f0db" />
<Button
android:id="@+id/bServices"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="@string/buttonServices" />
<Button
android:id="@+id/bTraining"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/bServices"
android:text="@string/buttonTraining"
android:background="#f7f0db" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_above="@+id/bAboutUs"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:contentDescription="@string/fblike"
android:src="@drawable/dgtklogo554a527" />
<Button
android:id="@+id/bAboutUs"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:background="#f7f0db"
android:layout_height="50dp"
android:layout_above="@+id/bServices"
android:layout_alignParentLeft="true"
android:text="@string/buttonAbtus" />
</RelativeLayout>
Please suggest what changes to do with the buttons to avoid such a situation.
Upvotes: 0
Views: 226
Reputation: 1973
Instead of using RelativeLayout use LinearLayout and set its orientation property vertical android:orientation="vertical"
then add item one by one you will achieve your layout.This will be memory efficient and fast compared to RelativeLayout as RelativeLayout depends on various relation between view and make view slow.
Thanks.
Upvotes: 2
Reputation: 41301
In case that you decide to stick with RelativeLayout
, the issue is that you have two groups of unrelated controls. Right now the relationship is the following:
bExit <- bContactus <- bInquiry
bServices <- bTraining
^
|
bAboutUs <- imageView1
Instead it should be like this:
bExit <- bContactus <- bInquiry <- bTraining <- bServices <- bAboutUs <- imageView1
Upvotes: 1