Weird unexplainable "switch" between ids in Android XML - android

I have a really weird problem.
This is my full XML code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<TextView android:id="#+id/disp_nums" android:textSize="64sp"
android:layout_width="200dp" android:layout_height="100dp"
android:layout_gravity="center" android:gravity="center" android:text="1111" />
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal">
<EditText android:id="#+id/ent_nums" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:hint="Entered numbers" />
<Button android:id="#+id/enter" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="0.37"
android:text="Enter" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="horizontal" android:layout_marginTop="15dp"
android:weightSum="90">
<Button android:id="#+id/button7" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="40sp"
android:text="7" android:layout_weight="30"/>
<Button android:id="#+id/button8" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="40sp"
android:text="8" android:layout_weight="30"/>
<Button android:id="#+id/button9" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="40sp"
android:text="9" android:layout_weight="30"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="horizontal" android:weightSum="90">
<Button android:id="#+id/button4" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="40sp"
android:text="4" android:layout_weight="30"/>
<Button android:id="#+id/button5" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="40sp"
android:text="5" android:layout_weight="30"/>
<Button android:id="#+id/button6" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="40sp"
android:text="6" android:layout_weight="30"/>
</LinearLayout>
<LinearLayout android:weightSum="90"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="horizontal">
<Button android:id="#+id/button1" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="40sp"
android:text="1" android:layout_weight="30"/>
<Button android:id="#+id/button2" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="40sp"
android:text="2" android:layout_weight="30"/>
<Button android:id="#+id/button3" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="40sp"
android:text="3" android:layout_weight="30"/>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:weightSum="90">
<Button android:id="#+id/button0" android:layout_width="90dp"
android:layout_height="wrap_content" android:layout_weight="60"
android:text="0" android:textSize="30sp" />
<Button android:id="#+id/delete" android:layout_width="40dp"
android:layout_height="fill_parent" android:layout_weight="30"
android:text="Del" android:textSize="24sp"/>
</LinearLayout>
</LinearLayout>
My "0" and "Del" buttons seem to be opposite in their actions. Meaning when I click "0" it actually deletes everything and when I click "Del" it types the "0" character. HOWEVER, when I simply switch (see second code) between their physical positions then they both do their right part.
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:weightSum="90">
<Button android:id="#+id/delete" android:layout_width="40dp"
android:layout_height="fill_parent" android:layout_weight="30"
android:text="Del" android:textSize="24sp"/>
<Button android:id="#+id/button0" android:layout_width="90dp"
android:layout_height="wrap_content" android:layout_weight="60"
android:text="0" android:textSize="30sp" />
</LinearLayout>
What could possibly be causing this?

Related

How to put these 9 buttons in 3 rows and let them fit

I'm trying to 9 buttons in 3 rows in one layout. However, as some of the buttons contains more text than the others the buttons don't fit. Now it looks like this:
I tried to put each row in a LinearLayout with weightSum = 3 but the rows disappear.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#32c6a6"
android:weightSum="3">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:id="#+id/kontaktfrag">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="13 egenskaber"
android:id="#+id/button"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="left|top"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Profeternes egenskaber"
android:id="#+id/button10"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="center_horizontal|top"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bøntider"
android:id="#+id/button2"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="right|top"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wudu"
android:id="#+id/button3"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="left|center_vertical"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wudu's betingelser"
android:id="#+id/button4"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="center"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wudu's afbrydelser"
android:id="#+id/button5"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="right|center_vertical"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bønnens søjler"
android:id="#+id/button6"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="left|bottom"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bønnens betingelser"
android:id="#+id/button7"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="center_horizontal|bottom"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bønnens afbrydelser"
android:id="#+id/button8"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="right|bottom"/>
</FrameLayout>
</LinearLayout >
Have also tried to use this solution, but it didn't solve my problem.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#32c6a6"
android:weightSum="3">
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/linRow1"
android:layout_weight="1"
android:weightSum="3">
<Button
android:text="13 egenskaber"
android:id="#+id/button"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:text="Profeternes egenskaber"
android:id="#+id/button10"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:text="Bøntider"
android:id="#+id/button2"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/linRow2"
android:layout_weight="1"
android:weightSum="3">
<Button
style="?android:attr/buttonStyleSmall"
android:text="Wudu"
android:id="#+id/button3"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:text="Wudu's betingelser"
android:id="#+id/button4"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
style="?android:attr/buttonStyleSmall"
android:text="Wudu's afbrydelser"
android:id="#+id/button5"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/linRow3"
android:layout_weight="1"
android:weightSum="3">
<Button
android:text="Bønnens søjler"
android:id="#+id/button6"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:text="Bønnens betingelser"
android:id="#+id/button7"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:text="Bønnens afbrydelser"
android:id="#+id/button8"
android:textSize="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
Check this
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:id="#+id/kontaktfrag">
<Button
android:layout_width="130dp"
android:layout_height="175dp"
android:text="13 egenskaber"
android:id="#+id/button"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="left|top"/>
<Button
android:layout_width="130dp"
android:layout_height="175dp"
android:text="Profeternes egenskaber"
android:id="#+id/button10"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="center_horizontal|top"/>
<Button
android:layout_width="130dp"
android:layout_height="175dp"
android:text="Bøntider"
android:id="#+id/button2"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="right|top"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="130dp"
android:layout_height="175dp"
android:text="Wudu"
android:id="#+id/button3"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="left|center_vertical"/>
<Button
android:layout_width="130dp"
android:layout_height="175dp"
android:text="Wudu's betingelser"
android:id="#+id/button4"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="center"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="130dp"
android:layout_height="175dp"
android:text="Wudu's afbrydelser"
android:id="#+id/button5"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="right|center_vertical"/>
<Button
android:layout_width="130dp"
android:layout_height="175dp"
android:text="Bønnens søjler"
android:id="#+id/button6"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="left|bottom"/>
<Button
android:layout_width="130dp"
android:layout_height="175dp"
android:text="Bønnens betingelser"
android:id="#+id/button7"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="center_horizontal|bottom"/>
<Button
android:layout_width="130dp"
android:layout_height="175dp"
android:text="Bønnens afbrydelser"
android:id="#+id/button8"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="right|bottom"/>
</FrameLayout>
Look at this. Define every button in the same size.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#32c6a6"
android:orientation="vertical>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/kontaktfrag"
android:weightSum="3">
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="13 egenskaber"
android:id="#+id/button"
android:textSize="15dp"
android:layout_gravity="left|top"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Profeternes egenskaber"
android:id="#+id/button10"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="center_horizontal|top"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bøntider"
android:id="#+id/button2"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="right|top"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wudu"
android:id="#+id/button3"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="left|center_vertical"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wudu's betingelser"
android:id="#+id/button4"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="center"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wudu's afbrydelser"
android:id="#+id/button5"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="right|center_vertical"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bønnens søjler"
android:id="#+id/button6"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="left|bottom"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bønnens betingelser"
android:id="#+id/button7"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="center_horizontal|bottom"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bønnens afbrydelser"
android:id="#+id/button8"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textSize="15dp"
android:layout_gravity="right|bottom"/>
</FrameLayout>
</LinearLayout >

Things move out of place on different screen sizes [duplicate]

This question already has answers here:
How to support different screen size in android
(9 answers)
Closed 8 years ago.
I've made an android app and spent quite a bit of time making it fit perfectly on my screen (specifically part marked as "this part" on xml). To my surprise, everything appears out of place in other screens. How do I make sure that it looks the same in all screens?
XML:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/wood"
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="com.luanca.charangomaster.ChordActivity"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:id="#+id/chordintip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/choose_root" />
<Button
android:id="#+id/chordin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/dark_plank"
android:text=""
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:id="#+id/emptymiddle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_toRightOf="#+id/emptymiddle"
android:layout_weight="1">
<TextView
android:id="#+id/chordintip2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/choose_type" />
<Button
android:id="#+id/chordin2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/dark_plank"
android:text=""
android:textColor="#ffffff" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/tip1"
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center"
android:text="#string/help" />
<!--This part doesn't fill all screens -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:scaleType="fitCenter"
android:src="#drawable/chord_box1"
/>
<LinearLayout
android:id="#+id/tabgrid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignBottom="#+id/imageView1"
android:layout_alignTop="#+id/imageView1"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:gravity="center_horizontal"
android:orientation="vertical"
android:weightSum="10" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="horizontal"></LinearLayout>
<LinearLayout
android:id="#+id/firstrow"
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_weight="1.15"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<Button
android:id="#+id/empty1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=""
android:visibility="invisible" />
<TextView
android:id="#+id/fretposition1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_weight="1"
android:gravity="center"
android:text="1"
android:textColor="#000000"/>
<TextView
android:id="#+id/fretposition2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_weight="1"
android:gravity="center"
android:text="2"
android:textColor="#000000"/>
<TextView
android:id="#+id/fretposition3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_weight="1"
android:gravity="center"
android:text="3"
android:textColor="#000000"/>
<TextView
android:id="#+id/fretposition4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_weight="1"
android:gravity="center"
android:text="4"
android:textColor="#000000"/>
<TextView
android:id="#+id/fretposition5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_weight="1"
android:gravity="center"
android:text="5"
android:textColor="#000000"/>
<Button
android:id="#+id/empty2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button"
android:visibility="invisible" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_alignTop="#+id/firstrow"
android:layout_weight="1.15"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<Button
android:id="#+id/empty4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.55"
android:text=""
android:visibility="invisible" />
<Button
android:id="#+id/fret10"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="-20dp"
android:layout_weight="1"
android:background="#drawable/no_press1"
android:text=""
android:textColor="#ffffff" />
<Button
android:id="#+id/fret11"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="1"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret12"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="2"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret13"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="3"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret14"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="4"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret15"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="1"
android:textColor="#ffffff" />
<Button
android:id="#+id/empty3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button"
android:visibility="invisible" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_weight="1.15"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<Button
android:id="#+id/empty5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.55"
android:text=""
android:visibility="invisible" />
<Button
android:id="#+id/fret20"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="-20dp"
android:layout_weight="1"
android:background="#drawable/no_press1"
android:text=""
android:textColor="#ffffff" />
<Button
android:id="#+id/fret21"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="1"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret22"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="2"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret23"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="3"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret24"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="4"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret25"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="1"
android:textColor="#ffffff" />
<Button
android:id="#+id/empty6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button"
android:visibility="invisible" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_weight="1.15"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<Button
android:id="#+id/empty7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.55"
android:text=""
android:visibility="invisible" />
<Button
android:id="#+id/fret30"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="-20dp"
android:layout_weight="1"
android:background="#drawable/no_press1"
android:text=""
android:textColor="#ffffff" />
<Button
android:id="#+id/fret31"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="1"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret32"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="2"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret33"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="3"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret34"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="4"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret35"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="1"
android:textColor="#ffffff" />
<Button
android:id="#+id/empty8"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button"
android:visibility="invisible" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_weight="1.15"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<Button
android:id="#+id/empty9"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.55"
android:text=""
android:visibility="invisible" />
<Button
android:id="#+id/fret40"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="-20dp"
android:layout_weight="1"
android:background="#drawable/no_press1"
android:text=""
android:textColor="#ffffff" />
<Button
android:id="#+id/fret41"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="1"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret42"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="2"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret43"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="3"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret44"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="4"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret45"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="1"
android:textColor="#ffffff" />
<Button
android:id="#+id/empty10"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=""
android:visibility="invisible" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="1.15"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<Button
android:id="#+id/empty11"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.55"
android:text=""
android:visibility="invisible" />
<Button
android:id="#+id/fret50"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="-20dp"
android:layout_weight="1"
android:background="#drawable/no_press1"
android:text=""
android:textColor="#ffffff" />
<Button
android:id="#+id/fret51"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="1"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret52"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="2"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret53"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="3"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret54"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="4"
android:textColor="#ffffff" />
<Button
android:id="#+id/fret55"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/finger1"
android:text="1"
android:textColor="#ffffff" />
<Button
android:id="#+id/empty12"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=""
android:visibility="invisible" />
</LinearLayout>
<Button
android:id="#+id/empty13"
android:layout_width="0dp"
android:layout_height="10dp"
android:layout_weight="1.15"
android:text=""
android:visibility="invisible" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:id="#+id/radioButton"
android:clickable="false"
android:checked="false"
android:visibility="gone" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:id="#+id/radioButton2"
android:clickable="false"
android:visibility="gone" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:id="#+id/radioButton3"
android:clickable="false"
android:visibility="gone" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:id="#+id/radioButton4"
android:clickable="false"
android:visibility="gone" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:id="#+id/radioButton5"
android:clickable="false"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
My drawables:
You can move all your dp values to dimen.xml, dimen.xml(large), etc. , and set different values for all screensizes.
You have to create different layouts (.xmls) for different different screen resolutions and place it in layout folder accordingly
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
Or else you have to create layout without hardcoded heights or widths and with the help of scrollViews you can access that view

Layout different on android 2.3

My buttons on 2.3 are not showing like the suppose to.
Anyone could help me?
This is how they are shown on 2.3:
And this is on 4.4 how it should be:
This is my layout on V9:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="#+id/numkeyBoard"
>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
style="#style/test.Button.Num"
android:id="#+id/button_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="1"
android:tag="1" />
<Button
style="#style/test.Button.Num"
android:id="#+id/button_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="2"
android:tag="2" />
<Button
style="#style/test.Button.Num"
android:text="3"
android:id="#+id/button_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:tag="3" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
style="#style/test.Button.Num"
android:text="4"
android:id="#+id/button_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:tag="4" />
<Button
style="#style/test.Button.Num"
android:text="5"
android:id="#+id/button_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:tag="5" />
<Button
style="#style/test.Button.Num"
android:text="6"
android:id="#+id/button_6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:tag="6" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
style="#style/test.Button.Num"
android:text="7"
android:id="#+id/button_7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:tag="7" />
<Button
style="#style/test.Button.Num"
android:text="8"
android:id="#+id/button_8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:tag="8" />
<Button
style="#style/test.Button.Num"
android:text="9"
android:id="#+id/button_9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:tag="9" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
style="#style/test.Button.Num"
android:text="C"
android:id="#+id/button_c"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:tag="C" />
<Button
style="#style/test.Button.Num"
android:text="0"
android:id="#+id/button_0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:tag="0"
/>
<Button
style="#style/test.Button.Num"
android:text="OK"
android:id="#+id/button_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:enabled="false"
android:tag="ok" />
</TableRow>
EDIT:
When I add a number second number to 1 2 3 ... until 9 then the buttons are all the same.
How can I fix this without adding a 2 digit?
Try adding android:stretchColumns="*" to the attributes defined under TableLayout

Custom Alert button overlapping

Ok i successfully created a custom alert and when i ran it the format is the same as in xml but after re-running it for the nth time suddenly the buttons overlap and I dont know how to fix it so can you pls help me out on this?.
alert.xml(output should be):
wrong output:
xml code:
<?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="#595959">
<EditText
android:id="#+id/orderQuantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/b3"
android:background="#FFFFFF"
android:ems="10"
android:inputType="number" />
<Button
android:id="#+id/b1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/b4"
android:layout_alignParentLeft="true"
android:text="1" />
<Button
android:id="#+id/b2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/orderQuantity"
android:layout_toRightOf="#+id/b4"
android:text="2" />
<Button
android:id="#+id/b3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/b4"
android:layout_centerHorizontal="true"
android:text="3" />
<Button
android:id="#+id/b4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/b2"
android:text="4" />
<Button
android:id="#+id/b5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/b2"
android:layout_toLeftOf="#+id/b3"
android:text="5" />
<Button
android:id="#+id/b6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/b5"
android:layout_alignBottom="#+id/b5"
android:layout_alignLeft="#+id/b3"
android:text="6" />
<Button
android:id="#+id/b7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/b4"
android:layout_toLeftOf="#+id/b5"
android:text="7" />
<Button
android:id="#+id/b8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/b4"
android:layout_toRightOf="#+id/b4"
android:text="8" />
<Button
android:id="#+id/b9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/b6"
android:layout_below="#+id/b6"
android:text="9" />
<Button
android:id="#+id/b0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/b8"
android:layout_toLeftOf="#+id/b9"
android:text="0" />
<Button
android:id="#+id/addCart"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/b0"
android:layout_alignParentLeft="true"
android:layout_below="#+id/b7"
android:layout_toLeftOf="#+id/b0"
android:text="ADD" />
<Button
android:id="#+id/cancel"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/b0"
android:layout_alignRight="#+id/b9"
android:layout_below="#+id/b9"
android:layout_toRightOf="#+id/b0"
android:text="BACK" />
</RelativeLayout>
Use LinearLayout instead of RelativeLayout. And remove these in Buttons:
android:layout_alignParentLeft="true"
after that it should be fine.
EDIT: Not just left alignment directives, but all alignment directives.
i would suggest you to use TableLayout ... very easy to understand and fits what you want perfectly and its easy to reuse or modify later ... your code ...
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<EditText
android:id="#+id/orderQuantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/b3"
android:background="#FFFFFF"
android:ems="10"
android:inputType="number" />
</TableRow>
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="1" />
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="2" />
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="3" />
</TableRow>
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="4" />
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="5" />
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="6" />
</TableRow>
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="7"/>
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="8"/>
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="9" />
</TableRow>
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Add"/>
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="0"/>
<Button
android:id="#+id/button1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="OK"/>
</TableRow>
</TableLayout>
Organize each row as below...
<Button
android:id="#+id/b1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/b4"
android:layout_alignParentLeft="true"
android:text="1" />
<Button
android:id="#+id/b2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/orderQuantity"
android:layout_toLeftOf="#+id/b3"
android:layout_toRightOf="#+id/b1"
android:text="2" />
<Button
android:id="#+id/b3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/b4"
android:layout_toRightOf="#+id/b2"
android:layout_centerHorizontal="true"
android:text="3" />
Ok after analyzing i was able to see whats wrong.
This
<Button
android:id="#+id/b3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/b4"
android:layout_centerHorizontal="true"
android:text="3" />
Should be :
<Button
android:id="#+id/b3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/b4"
android:text="3" />
I would do something 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="wrap_content"
android:orientation="vertical"
android:background="#595959">
<EditText
android:id="#+id/orderQuantity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/b3"
android:background="#FFFFFF"
android:ems="10"
android:inputType="number"/>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<Button
android:id="#+id/b1"
android:layout_width="0dp"
android:layout_weight=".3333"
android:layout_height="match_parent"
android:text="1"/>
<Button
android:id="#+id/b2"
android:layout_width="0dp"
android:layout_weight=".3333"
android:layout_height="match_parent"
android:text="2"/>
<Button
android:id="#+id/b3"
android:layout_width="0dp"
android:layout_weight=".3333"
android:layout_height="match_parent"
android:text="3"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<Button
android:id="#+id/b4"
android:layout_width="0dp"
android:layout_weight=".3333"
android:layout_height="match_parent"
android:text="4"/>
<Button
android:id="#+id/b5"
android:layout_width="0dp"
android:layout_weight=".3333"
android:layout_height="match_parent"
android:text="5"/>
<Button
android:id="#+id/b6"
android:layout_width="0dp"
android:layout_weight=".3333"
android:layout_height="match_parent"
android:text="6"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<Button
android:id="#+id/b7"
android:layout_width="0dp"
android:layout_weight=".3333"
android:layout_height="match_parent"
android:text="7"/>
<Button
android:id="#+id/b8"
android:layout_width="0dp"
android:layout_weight=".3333"
android:layout_height="match_parent"
android:text="8"/>
<Button
android:id="#+id/b9"
android:layout_width="0dp"
android:layout_weight=".3333"
android:layout_height="match_parent"
android:text="9"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<Button
android:id="#+id/b0"
android:layout_width="0dp"
android:layout_weight=".3333"
android:layout_height="match_parent"
android:text="0"/>
<Button
android:id="#+id/addCart"
android:layout_width="0dp"
android:layout_weight=".3333"
android:layout_height="match_parent"
android:text="ADD"/>
<Button
android:id="#+id/cancel"
android:layout_width="0dp"
android:layout_weight=".3333"
android:layout_height="match_parent"
android:text="BACK"/>
</LinearLayout>
</LinearLayout>

LinearLayout doesn't fill the window

I have set up 4 linear layouts: 2 vertical ones, side by side and 2 horizontal ones, arranged vertically.
This will give me a total of 3 vertical ones.
Then end goal is to have one layout for multiple screen sizes.
I set the weight of all 4 layouts to "1" to fill evenly.
I have tried to use android:layout_height="wrap_content", but it does not fill the entire background.
If I use android:layout_height="fill_parent", the layouts get clipped.
Here is screenshot of "wrap_content"
Here is screenshot of "fill_parent"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff606060"
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=".SimpleRGB_Main" >
<LinearLayout
android:id="#+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_weight="1"
android:orientation="vertical" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
android:layout_weight="1"
android:text="Scene 1" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button1"
android:layout_marginLeft="0dp"
android:layout_weight="1"
android:text="Scene 2" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button2"
android:layout_marginLeft="0dp"
android:layout_weight="1"
android:text="Scene 3" />
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button3"
android:layout_marginLeft="0dp"
android:layout_weight="1"
android:text="Scene 4" />
<Button
android:id="#+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button4"
android:layout_marginLeft="0dp"
android:layout_weight="1"
android:text="Scene 5" />
</LinearLayout>
<LinearLayout
android:id="#+id/relativeLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/relativeLayout1"
android:layout_weight="1"
android:orientation="vertical" >
<Button
android:id="#+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_toRightOf="#+id/button1"
android:layout_weight="1"
android:text="Scene 6" />
<Button
android:id="#+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button6"
android:layout_toRightOf="#+id/button2"
android:layout_weight="1"
android:text="Scene7" />
<Button
android:id="#+id/button8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button7"
android:layout_toRightOf="#+id/button3"
android:layout_weight="1"
android:text="Scene8" />
<Button
android:id="#+id/button9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button8"
android:layout_toRightOf="#+id/button4"
android:layout_weight="1"
android:text="Scene9" />
<Button
android:id="#+id/button10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button9"
android:layout_toRightOf="#+id/button5"
android:layout_weight="1"
android:text="Scene10" />
</LinearLayout>
<LinearLayout
android:id="#+id/relativeLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/relativeLayout1"
android:layout_weight="1"
android:orientation="horizontal" >
<Button
android:id="#+id/button11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="RECORD" />
<Button
android:id="#+id/button12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="PLAY" />
</LinearLayout>
<LinearLayout
android:id="#+id/relativeLayout4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/relativeLayout3"
android:layout_weight="1"
android:orientation="horizontal" >
<Button
android:id="#+id/button11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="RECORD1" />
<Button
android:id="#+id/button12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="PLAY1" />
</LinearLayout>
Here is what I am trying to attempt. Green is the layouts filled with buttons and or widgets.
Putting layout weights on children of RelativeLayout does not work. Weights only work on LinearLayout (that is, children of linear layout, not linear layout itself). Try starting by making your root layout linear, not RelativeLayout.
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff606060"
android:weightSum="6"
android:layout_gravity="fill_horizontal|center_vertical"
tools:context=".SimpleRGB_Main" >
<TableRow
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:weightSum="2"
android:layout_weight="1">
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
android:layout_weight="1"
android:text="Scene 1" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button1"
android:layout_marginLeft="0dp"
android:layout_weight="1"
android:text="Scene 6" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:weightSum="2">
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button2"
android:layout_marginLeft="0dp"
android:layout_weight="1"
android:text="Scene 2" />
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button3"
android:layout_marginLeft="0dp"
android:layout_weight="1"
android:text="Scene 7" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
android:weightSum="2">
<Button
android:id="#+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button4"
android:layout_marginLeft="0dp"
android:layout_weight="1"
android:text="Scene 3" />
<Button
android:id="#+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_toRightOf="#+id/button1"
android:layout_weight="1"
android:text="Scene 8" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:weightSum="2">
<Button
android:id="#+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button6"
android:layout_toRightOf="#+id/button2"
android:layout_weight="1"
android:text="Scene 4" />
<Button
android:id="#+id/button8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button7"
android:layout_toRightOf="#+id/button3"
android:layout_weight="1"
android:text="Scene 9" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="2"
android:layout_weight="1">
<Button
android:id="#+id/button9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button8"
android:layout_toRightOf="#+id/button4"
android:layout_weight="1"
android:text="Scene 5" />
<Button
android:id="#+id/button10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button9"
android:layout_toRightOf="#+id/button5"
android:layout_weight="1"
android:text="Scene 10" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
android:weightSum="2">
<Button
android:id="#+id/button11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="RECORD" />
<Button
android:id="#+id/button12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="RECORD 1" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
android:weightSum="2">
<Button
android:id="#+id/button11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="PLAY " />
<Button
android:id="#+id/button12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="PLAY 1" />
</TableRow>
</TableLayout>
graphical view

Categories

Resources