I have made a simple application, with a background image, 4 image buttons and 4 text views in front of them.
I've read the google development documentation, but I still don't understand why in screens with a different size of 4,7" the app doesn't run normally. The textview is not in the right place. The image buttons are too small or too big in wrong places
I've created different images for differente resolutions (ldpi, mdpi, hdpi,xhdpi).
Here is the xml file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/gameinterface"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".QuestionsActivity" >
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="95dp"
android:layout_marginRight="10dp"
android:layout_marginTop="137dp"
android:orientation="vertical" >
<TextView
android:id="#+id/tvQuestion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:gravity="center_vertical|center_horizontal"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/white"
android:textSize="30sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" >
<TextView
android:id="#+id/tvNumQuestion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#B22222"
android:textSize="30sp" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/20"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#B22222"
android:textSize="30sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/linearLayout3"
android:layout_alignLeft="#+id/linearLayout4"
android:layout_marginBottom="114dp" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageButton
android:id="#+id/btnR1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/selector"
android:src="#drawable/answerbutton" />
<TextView
android:id="#+id/tvR1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#android:color/white"
android:textSize="10sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp" >
<ImageButton
android:id="#+id/btnR3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/selector"
android:src="#drawable/answerbutton" />
<TextView
android:id="#+id/tvR3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#android:color/white"
android:textSize="10sp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageButton
android:id="#+id/btnR2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/selector"
android:src="#drawable/answerbutton" />
<TextView
android:id="#+id/tvR2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#android:color/white"
android:textSize="10sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp" >
<ImageButton
android:id="#+id/btnR4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/selector"
android:src="#drawable/answerbutton" />
<TextView
android:id="#+id/tvR4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#android:color/white"
android:textSize="10sp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Related
<?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="#00b9e8"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin" >
<RelativeLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:background="#ffffff" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Serch"
android:textColor="#000"
android:textSize="20sp" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/textView2"
android:layout_marginRight="32dp"
android:src="#drawable/backbutton" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#6AED83"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Footer"
android:textColor="#000000"
android:textSize="20sp" />
</RelativeLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="122dp"
android:text="Enter Mobile Number"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffffff"
android:textSize="20dp" />
<LinearLayout
android:id="#+id/layout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView1"
android:layout_marginLeft="14dp"
android:layout_marginTop="16dp"
android:background="#drawable/roundedlinearlayout3"
android:weightSum="4" >
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/user_s_icon" />
<EditText
android:id="#+id/editText1"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:hint="Enter Mobile Number"
android:textColorHint="#0060a4" >
</EditText>
</LinearLayout>
<Button
android:id="#+id/signin"
android:layout_width="244dip"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/layout1"
android:layout_below="#+id/layout1"
android:layout_marginTop="27dp"
android:background="#drawable/rounded"
android:text="Search"
android:textColor="#ffffff"
android:textSize="10pt" />
</RelativeLayout>
This is my Xml i am Unable to set Linear layout inside text view and image button Like desire image:
This is my desire screen : below is my current screen :
i am unable to set text-view and image view on top of Linear layout
Try this way,hope this will help you to solve your problem.
Instead of using RelativeLayout use LinearLayout which can be easily done your requirement.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00b9e8"
android:orientation="vertical">
<LinearLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:gravity="center"
android:background="#ffffff" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Serch"
android:textColor="#000"
android:textSize="20sp" />
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1"/>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/backbutton" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter Mobile Number"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffffff"
android:textSize="20dp" />
<LinearLayout
android:id="#+id/layout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1"
android:layout_marginTop="10dp"
android:background="#drawable/roundedlinearlayout3">
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Mobile Number"
android:textColorHint="#0060a4"
android:drawableLeft="#drawable/user_s_icon">
</EditText>
</LinearLayout>
<Button
android:id="#+id/signin"
android:layout_width="244dip"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/rounded"
android:text="Search"
android:textColor="#ffffff"
android:textSize="10pt" />
</LinearLayout>
<LinearLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#6AED83"
android:gravity="center"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Footer"
android:textColor="#000000"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
I am trying to use the design tab in Android Studio to design my XML for my homescreen, however when i try and drag a button it realigned everything on the layout, eg like in the image below:
I want to arrange it so the buttons are a uniform size and aligned in a 2x3 table like the following
a b
c d
e f
I would like the image to remain in the same place as it is currently, with the text underneath also not to move.
Current XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:src="#drawable/amityapplogo"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/welcomeadmin"
android:id="#+id/textView"
android:layout_gravity="center_horizontal"
android:layout_below="#+id/imageView"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/mydetails"
android:id="#+id/mydetailsbutton"
android:layout_gravity="center_horizontal"
android:clickable="false"
android:layout_toStartOf="#+id/myhealthbutton"
android:layout_below="#+id/textView"
android:layout_centerHorizontal="true"
android:layout_marginTop="42dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/policydetails"
android:id="#+id/policydetailsbutton"
android:layout_gravity="center_horizontal"
android:layout_alignTop="#+id/mydetailsbutton"
android:layout_toRightOf="#+id/findaproviderbutton"
android:layout_toEndOf="#+id/findaproviderbutton" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/myhealth"
android:id="#+id/myhealthbutton"
android:layout_gravity="center_horizontal"
android:layout_toStartOf="#+id/contactusbutton"
android:layout_centerVertical="true"
android:layout_alignLeft="#+id/textView"
android:layout_alignStart="#+id/textView" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/findaprovider"
android:id="#+id/findaproviderbutton"
android:layout_gravity="center_horizontal"
android:layout_toStartOf="#+id/myhealthbutton"
android:layout_below="#+id/visitourwebsitebutton"
android:layout_alignLeft="#+id/imageView"
android:layout_alignStart="#+id/imageView" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/contactus"
android:id="#+id/contactusbutton"
android:layout_gravity="center_horizontal"
android:layout_toEndOf="#+id/textView"
android:layout_below="#+id/visitourwebsitebutton"
android:layout_alignRight="#+id/imageView"
android:layout_alignEnd="#+id/imageView"
android:layout_marginTop="40dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/visitourwebsite"
android:id="#+id/visitourwebsitebutton"
android:layout_gravity="center_horizontal"
android:layout_toEndOf="#+id/myhealthbutton"
android:layout_alignBaseline="#+id/myhealthbutton"
android:layout_alignBottom="#+id/myhealthbutton"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
Cheers in advance!
Added tablerows, now all is aligned to the left hand side:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="fill_horizontal"
android:id="#+id/">
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:src="#drawable/amityapplogo" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/welcomeadmin"
android:id="#+id/textView"
android:layout_gravity="center_horizontal" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_column="1"
android:orientation="horizontal"
android:id="#+id/">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/mydetails"
android:id="#+id/mydetailsbutton"
android:layout_column="0" />
</TableRow>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/policydetails"
android:id="#+id/policydetailsbutton" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/myhealth"
android:id="#+id/myhealthbutton" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/findaprovider"
android:id="#+id/findaproviderbutton" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/visitourwebsite"
android:id="#+id/visitourwebsitebutton" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/contactus"
android:id="#+id/contactusbutton"
android:layout_gravity="center_vertical" />
</TableRow>
</TableLayout>
Try this and let me know
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:src="#drawable/amityapplogo"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/welcomeadmin"
android:id="#+id/textView"
android:layout_gravity="center_horizontal"
android:layout_below="#+id/imageView"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/mydetails"
android:id="#+id/mydetailsbutton"
android:clickable="false"
android:layout_marginTop="36dp"
android:layout_below="#+id/findaproviderbutton"
android:layout_alignRight="#+id/myhealthbutton"
android:layout_alignEnd="#+id/myhealthbutton" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/policydetails"
android:id="#+id/policydetailsbutton"
android:layout_toStartOf="#+id/mydetailsbutton"
android:layout_above="#+id/findaproviderbutton"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="36dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/myhealth"
android:id="#+id/myhealthbutton"
android:layout_toEndOf="#+id/imageView"
android:layout_below="#+id/policydetailsbutton"
android:layout_alignLeft="#+id/imageView"
android:layout_alignStart="#+id/imageView" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/findaprovider"
android:id="#+id/findaproviderbutton"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="#+id/mydetailsbutton"
android:layout_toStartOf="#+id/mydetailsbutton" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/contactus"
android:id="#+id/contactusbutton"
android:layout_toEndOf="#+id/imageView"
android:layout_alignBottom="#+id/policydetailsbutton"
android:layout_alignLeft="#+id/myhealthbutton"
android:layout_alignStart="#+id/myhealthbutton" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/visitourwebsite"
android:id="#+id/visitourwebsitebutton"
android:layout_toEndOf="#+id/policydetailsbutton"
android:layout_alignBottom="#+id/mydetailsbutton"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="#+id/contactusbutton"
android:layout_toStartOf="#+id/contactusbutton" />
</RelativeLayout>
Here is what it look without assets
Comes to this(At Paul's , with assets):
This might work
<?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:orientation="vertical" >
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:text="ggggg"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/mydetailsbutton"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/textView"
android:layout_marginTop="42dp"
android:text="Details" />
<Button
android:id="#+id/policydetailsbutton"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/mydetailsbutton"
android:layout_alignTop="#id/mydetailsbutton"
android:layout_alignBottom="#id/mydetailsbutton"
android:text="eeeee" />
<Button
android:id="#+id/myhealthbutton"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="#id/mydetailsbutton"
android:layout_alignLeft="#id/mydetailsbutton"
android:layout_alignRight="#id/mydetailsbutton"
android:text="ddddd" />
<Button
android:id="#+id/findaproviderbutton"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="#id/mydetailsbutton"
android:layout_alignLeft="#id/policydetailsbutton"
android:layout_alignRight="#id/policydetailsbutton"
android:text="ccccc" />
<Button
android:id="#+id/contactusbutton"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="#id/myhealthbutton"
android:layout_alignLeft="#id/mydetailsbutton"
android:layout_alignRight="#id/mydetailsbutton"
android:text="bbbbb" />
<Button
android:id="#+id/visitourwebsitebutton"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="#id/myhealthbutton"
android:layout_alignLeft="#id/policydetailsbutton"
android:layout_alignRight="#id/policydetailsbutton"
android:text="aaaaa" />
</RelativeLayout>
You can use LinearLayouts inside another LinearLayout just like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:text="Button1" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:text="Button2" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:text="Button3" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:text="Button4" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:text="Button5" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:text="Button6" />
</LinearLayout>
</LinearLayout>
You can add the ImageView and TextView before the first LinearLayout that keeps the first two Buttons.
The layout I'm designing appears fine in graphical layout but when I install it on the device it screws up.
Graphical Layout
On device
Here is my layout file.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/home_background"
>
<HorizontalScrollView
android:id="#+id/horizontalScrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/relativeLayout1"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="81dp"
android:scrollbars="none"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dp"
android:src="#drawable/flipkart" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:src="#drawable/dominos" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:src="#drawable/flipkart" />
</LinearLayout>
</HorizontalScrollView>
<ImageView
android:id="#+id/dotted_separator"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/relativeLayout1"
android:layout_marginTop="17dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:src="#drawable/dotted_separator" />
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:padding="30dp" >
<LinearLayout
android:id="#+id/title_holder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/find_restaurant_coupons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="Find Restaurant Coupons"
android:textColor="#ffffff"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/spinner_holder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/title_holder"
>
<!--
<Spinner
android:id="#+id/city_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="#array/city_spinner_data"
/>
-->
</LinearLayout>
<LinearLayout
android:id="#+id/location_search_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/spinner_holder"
>
<EditText
android:id="#+id/input_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffff"
android:ems="10"
android:hint="Location"
android:inputType="text"
android:padding="10dp"
android:textColor="#000000" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button_go"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/input_location"
android:background="#17b851"
android:padding="10dp"
android:text="GO" />
</LinearLayout>
</RelativeLayout>
<Button
android:id="#+id/best_restaurants_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/horizontalScrollView1"
android:layout_marginBottom="14dp"
android:layout_marginRight="42dp"
android:background="#17b851"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:text="Best Restaurants Offers" />
</RelativeLayout>
I dont understand what the problem was. I again stared with a blank file and copied each block one at a time to narrow down the problem but to my surprise this time it shows up properly.
i tried designing an xml layout for my android app. It looks good in eclipse graphical layout of android api level 10. But when i run the same in my android device of 2.3.3(api level 10),
that layout looks completely different.
After the text title in the top everything gets changed
I have attached the screen shot of my graphical layout in eclipse and image from my android device
Following is my xml file
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/frame2_include"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#drawable/bg">
<LinearLayout
android:id="#+id/title_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top">
<include
android:id="#+id/title_include"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="#layout/title" />
</LinearLayout>
<RelativeLayout
android:id="#+id/r_title_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/title_bg">
<TextView
android:id="#+id/normal_title_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/app"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/r_frame_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/r_title_layout">
<ViewSwitcher
android:id="#+id/r_frame_viewSwitcher1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/r_frame_image_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:background="#color/white"
android:layout_gravity="center_vertical">
<RelativeLayout
android:id="#+id/r_round_points"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/points_bg" >
<LinearLayout
android:id="#+id/r_center_frame_img_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<TextView
android:id="#+id/r_frame_img_txt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30dp"
android:text="50"
android:textColor="#000000"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/r_frame_img_txt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Points"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/r_frame_map_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include
android:id="#+id/parii_me_map_view2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
layout="#layout/parii_map" />
</LinearLayout>
</ViewSwitcher>
<RelativeLayout
android:id="#+id/r_merge_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="105dp"
android:background="#android:color/transparent">
<ImageView
android:contentDescription="#string/app_name"
android:id="#+id/merge_bg_img"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/title_bg"
android:layout_centerInParent="true"/>
<RelativeLayout
android:id="#+id/merge_view_pro_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/merge_center_img"
android:layout_centerVertical="true">
<TextView
android:id="#+id/merge_view_pro_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/mrg_profile"
android:layout_centerInParent="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
<ImageView
android:contentDescription="#string/app_name"
android:id="#+id/merge_center_img"
android:layout_width="73dp"
android:layout_height="73dp"
android:layout_centerInParent="true"
android:background="#drawable/ic_launcher" />
<RelativeLayout
android:id="#+id/merge_view_cash_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/merge_center_img"
android:layout_centerVertical="true">
<TextView
android:id="#+id/merge_view_cash_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/mrg_cash"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/r_edit_box_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="185dp">
<TextView
android:id="#+id/r_remaining_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="7dp"
android:layout_marginRight="3dp"
android:gravity="center|center_horizontal"
android:text="200"
android:textColor="#color/black"
android:background="#drawable/ponts_field"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/r_remaining_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/r_remaining_label"
android:text="#string/Reamins"
android:layout_centerVertical="true"
android:textColor="#color/black"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/r_points_txt"
android:layout_toLeftOf="#+id/r_points_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Parii_Pts"
android:layout_centerVertical="true"
android:gravity="center"
android:textColor="#color/black"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/r_points_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="7dp"
android:layout_marginLeft="3dp"
android:text="100"
android:gravity="center|center_horizontal"
android:textColor="#color/black"
android:background="#drawable/ponts_field"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
</RelativeLayout>
<TextView
android:id="#+id/r_items_viewed_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_below="#+id/r_frame_layout"
android:maxLines="2"
android:textColor="#color/black"
android:textAppearance="?android:attr/textAppearanceSmall" />
<RelativeLayout
android:id="#+id/r_bottom_map_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/r_items_viewed_txt"
android:layout_marginTop="20dp">
<TextView
android:id="#+id/r_valid_date"
android:layout_toLeftOf="#+id/r_points_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:textColor="#color/black"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageButton
android:contentDescription="#string/app_name"
android:id="#+id/parii_me_details_switch_mapBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:layout_centerVertical="true"
android:background="#drawable/map_sel_btn" />
</RelativeLayout>
</FrameLayout>
Pls say me where i am going wrong
try this:
only replace that by default image by your circle image having 50 pts inside.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#aba4a4">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/l1">
<Button
android:id="#+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Back btn"
android:textColor="#121212"
android:textSize="18dp" />
<TextView
android:id="#+id/txt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Rewards"
android:textColor="#android:color/black"
android:textSize="18dp"
android:textStyle="bold"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"/>
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/l2"
android:layout_below="#+id/l1"
android:background="#7d7373">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textSize="18dp"
android:layout_centerHorizontal="true"
android:textColor="#android:color/white"/>
</RelativeLayout>
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_below="#+id/l2"
android:background="#drawable/ic_launcher"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/l3"
android:background="#7d7373"
android:layout_centerInParent="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Profile"
android:textSize="18dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:textColor="#android:color/white"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="View"
android:textSize="18dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:textColor="#android:color/white"
android:layout_marginRight="20dp"/>
</RelativeLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher"
android:layout_centerInParent="true"/>
</RelativeLayout>
Add the remaining view in it.i think this must solve your issue.
i am making android UI (using Relative Layout)in which, i need to set one banner whose size is 306 x 51. i have set it as center of screen. and it getting displayed well in some android mobile screen but when i run in tablet then display is like:
as shown in the image, space are remain left and right side. so what i do for it?
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="#drawable/page1_11"
android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_01" android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView android:layout_height="wrap_content"
android:layout_width="match_parent" android:src="#drawable/page1_1"
android:id="#+id/imageView1" android:layout_alignParentLeft="true" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="Shanesh COLORS App"
android:textSize="13dp" android:textStyle="bold" android:textColor="#49515F"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_below="#+id/login_rellay_01" android:id="#+id/login_rellay_02"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:src="#drawable/page1_4"
android:id="#+id/imageView1" android:layout_centerHorizontal="true" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="SIGN IN"
android:textSize="13dp" android:textStyle="bold" android:textColor="#FFFFFF"
android:layout_centerInParent="true" />
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/page1_2"
android:layout_centerVertical="true" android:layout_marginLeft="10dp" />
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/page1_3"
android:layout_centerVertical="true" android:layout_marginRight="10dp"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_03" android:layout_below="#+id/login_rellay_02"
android:layout_width="match_parent" android:layout_height="wrap_content">
<ImageView android:layout_height="wrap_content"
android:layout_width="match_parent" android:src="#drawable/page1_5"
android:id="#+id/imgv_page1_5" android:layout_alignParentLeft="true" />
<!-- <ImageView android:layout_height="wrap_content" android:layout_below="#+id/imgv_page1_5"
android:layout_marginTop="1dp" android:layout_width="match_parent" android:src="#drawable/page1_6"
android:id="#+id/imgv_page1_6" android:layout_alignParentLeft="true" /> -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_03" android:layout_centerInParent="true"
android:layout_below="#+id/login_rellay_02" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="SIGN IN "
android:textSize="13dp" android:id="#+id/login_txvx_dwbnr_1"
android:textStyle="bold" android:textColor="#000000"
android:layout_marginLeft="10dp" android:layout_centerVertical="true" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="with your "
android:id="#+id/login_txvx_dwbnr_2" android:layout_toRightOf="#+id/login_txvx_dwbnr_1"
android:textSize="13dp" android:layout_centerVertical="true"
android:textColor="#000000" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="Shanesh Colors"
android:id="#+id/login_txvx_dwbnr_3" android:layout_toRightOf="#+id/login_txvx_dwbnr_2"
android:textSize="13dp" android:textStyle="bold"
android:layout_centerVertical="true" android:textColor="#000000" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text=" App Account "
android:id="#+id/login_txvx_dwbnr_4" android:layout_toRightOf="#+id/login_txvx_dwbnr_3"
android:textSize="13dp" android:layout_centerVertical="true"
android:textColor="#000000" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_04" android:layout_marginTop="1dp"
android:gravity="center" android:layout_below="#+id/login_rellay_03"
android:layout_width="match_parent" android:layout_height="wrap_content">
<ImageView android:layout_height="180dp"
android:layout_width="306dp" android:background="#FFFFFF" android:id="#+id/imgv_page1_6"
android:layout_centerInParent="true" />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_04" android:layout_width="match_parent"
android:layout_height="wrap_content" android:gravity="center">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="User Name:"
android:id="#+id/login_txvx_dwbnr_5" android:layout_toRightOf="#+id/login_txvx_dwbnr_1"
android:textSize="11dp" android:layout_centerVertical="true"
android:textColor="#49515F" />
<EditText android:layout_height="40dp" android:layout_width="220dp"
android:layout_marginTop="10dp" android:layout_toRightOf="#+id/login_txvx_dwbnr_5" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_05" android:layout_width="match_parent"
android:layout_height="wrap_content" android:gravity="center"
android:layout_below="#+id/login_rellay_04">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text=" Password:"
android:id="#+id/login_txvx_dwbnr_5"
android:layout_toRightOf="#+id/login_txvx_dwbnr_1"
android:textSize="11dp"
android:layout_centerVertical="true"
android:textColor="#49515F" />
<EditText android:layout_height="40dp" android:layout_width="220dp"
android:layout_alignParentTop="true" android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/login_txvx_dwbnr_5" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_06"
android:layout_marginTop="3dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_below="#+id/login_rellay_05"
android:layout_width="match_parent">
<TextView android:layout_height="wrap_content"
android:textColor="#000000"
android:text="No Account?"
android:textStyle="bold"
android:textSize="11dp"
android:id="#+id/login_txvx_dwbnr_9"
android:layout_width="wrap_content"/>
<TextView android:text="Sign Up"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="#+id/login_txvx_signup_account"
android:textColor="#8891A2"
android:textStyle="bold"
android:layout_toRightOf="#+id/login_txvx_dwbnr_9"
android:textSize="11dp"
/></RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_07"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_below="#+id/login_rellay_06"
android:layout_width="match_parent">
<CheckBox android:layout_height="wrap_content"
android:id="#+id/checkBox1"
android:layout_below="#+id/login_txvx_signup_account"
android:layout_width="wrap_content"
android:textColor="#49515F"
android:textSize="11dp"
android:layout_marginLeft="10dp"
android:text=" Remember User Name and Password?"
/>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_08"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginTop="60dp"
android:layout_below="#+id/login_rellay_04"
android:layout_width="match_parent">
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="#drawable/page1_8"
/>
</RelativeLayout>
</RelativeLayout>
#zam664 is right ... u should never use fixed widths for Layouts.. try managing them by padding, margins etc.
Use LinearLayout too to manage horizontal children with non-fixed width..
anyway... i modified ur xml a little ... i could not test it fully as i did not have the images/resources u have used in it.. but give it a try.
Replace the whole xml with the following. ...
Note: a have just changed it a little to give you idea ... u should modify it further if that works
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="#drawable/page1_11"
android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_01" android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView android:layout_height="wrap_content"
android:layout_width="match_parent" android:src="#drawable/page1_1"
android:id="#+id/imageView1" android:layout_alignParentLeft="true" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="Shanesh COLORS App"
android:textSize="13dp" android:textStyle="bold" android:textColor="#49515F"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_below="#+id/login_rellay_01" android:id="#+id/login_rellay_02"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageView android:layout_height="wrap_content"
android:layout_width="fill_parent" android:src="#drawable/page1_4"
android:id="#+id/imageView1" android:layout_centerHorizontal="true" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="SIGN IN"
android:textSize="13dp" android:textStyle="bold" android:textColor="#FFFFFF"
android:layout_centerInParent="true" />
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/page1_2"
android:layout_centerVertical="true" android:layout_marginLeft="10dp" />
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/page1_3"
android:layout_centerVertical="true" android:layout_marginRight="10dp"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_03" android:layout_below="#+id/login_rellay_02"
android:layout_width="match_parent" android:layout_height="wrap_content">
<ImageView android:layout_height="wrap_content"
android:layout_width="match_parent" android:src="#drawable/page1_5"
android:id="#+id/imgv_page1_5" android:layout_alignParentLeft="true" />
<!-- <ImageView android:layout_height="wrap_content" android:layout_below="#+id/imgv_page1_5"
android:layout_marginTop="1dp" android:layout_width="match_parent" android:src="#drawable/page1_6"
android:id="#+id/imgv_page1_6" android:layout_alignParentLeft="true" /> -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_03" android:layout_centerInParent="true"
android:layout_below="#+id/login_rellay_02" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="SIGN IN "
android:textSize="13dp" android:id="#+id/login_txvx_dwbnr_1"
android:textStyle="bold" android:textColor="#000000"
android:layout_marginLeft="10dp" android:layout_centerVertical="true" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="with your "
android:id="#+id/login_txvx_dwbnr_2" android:layout_toRightOf="#+id/login_txvx_dwbnr_1"
android:textSize="13dp" android:layout_centerVertical="true"
android:textColor="#000000" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="Shanesh Colors"
android:id="#+id/login_txvx_dwbnr_3" android:layout_toRightOf="#+id/login_txvx_dwbnr_2"
android:textSize="13dp" android:textStyle="bold"
android:layout_centerVertical="true" android:textColor="#000000" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text=" App Account "
android:id="#+id/login_txvx_dwbnr_4" android:layout_toRightOf="#+id/login_txvx_dwbnr_3"
android:textSize="13dp" android:layout_centerVertical="true"
android:textColor="#000000" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_04" android:layout_marginTop="1dp"
android:gravity="center" android:layout_below="#+id/login_rellay_03"
android:layout_width="match_parent" android:layout_height="wrap_content">
<ImageView android:layout_height="fill_parent"
android:layout_width="fill_parent" android:background="#FFFFFF" android:id="#+id/imgv_page1_6"
android:layout_centerInParent="true" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_04" android:layout_width="match_parent"
android:layout_height="wrap_content" android:orientation="horizontal"
android:paddingLeft="10dp" android:paddingRight="10dp">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="User Name:"
android:id="#+id/login_txvx_dwbnr_5" android:layout_toRightOf="#+id/login_txvx_dwbnr_1"
android:textSize="11dp" android:layout_centerVertical="true"
android:textColor="#49515F" />
<EditText android:layout_height="40dp" android:layout_width="fill_parent" android:layout_weight="1"
android:layout_marginTop="10dp" android:layout_marginLeft="10dp"/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_05" android:layout_width="match_parent"
android:layout_height="wrap_content" android:orientation="horizontal"
android:paddingLeft="10dp" android:paddingRight="10dp"
android:layout_below="#+id/login_rellay_04">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text=" Password:"
android:id="#+id/login_txvx_dwbnr_5"
android:layout_toRightOf="#+id/login_txvx_dwbnr_1"
android:textSize="11dp"
android:layout_centerVertical="true"
android:textColor="#49515F" />
<EditText android:layout_height="40dp" android:layout_width="fill_parent" android:layout_weight="1"
android:layout_alignParentTop="true" android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/login_txvx_dwbnr_5" />
</LinearLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_06"
android:layout_marginTop="3dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_below="#+id/login_rellay_05"
android:layout_width="match_parent">
<TextView android:layout_height="wrap_content"
android:textColor="#000000"
android:text="No Account?"
android:textStyle="bold"
android:textSize="11dp"
android:id="#+id/login_txvx_dwbnr_9"
android:layout_width="wrap_content"/>
<TextView android:text="Sign Up"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="#+id/login_txvx_signup_account"
android:textColor="#8891A2"
android:textStyle="bold"
android:layout_toRightOf="#+id/login_txvx_dwbnr_9"
android:textSize="11dp"
/></RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_07"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_below="#+id/login_rellay_06"
android:layout_width="match_parent">
<CheckBox android:layout_height="wrap_content"
android:id="#+id/checkBox1"
android:layout_below="#+id/login_txvx_signup_account"
android:layout_width="wrap_content"
android:textColor="#49515F"
android:textSize="11dp"
android:layout_marginLeft="10dp"
android:text=" Remember User Name and Password?"
/>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_08"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginTop="60dp"
android:layout_below="#+id/login_rellay_04"
android:layout_width="match_parent">
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="#drawable/page1_8"
/>
</RelativeLayout>
You cannot used fixed dimensions if your aspect ratio or screen sizes are expected to vary. That is why Java focused on layout managers to be more platform agnostic than previous Windows development methods which forced dimensions. Forced dimensions are bad.
This is because your tablet width is more than 306. so the banner is showing at center of the screen but taking width required for the banner image. try following
you are using
android:layout_width="wrap_content"
for ImageView in which you are setting your banner
please try using
android:layout_width="match_parent"
instead. Another way is try to put big size banner image in /drawable-xlarge folder to match your tablet screen size