Layout issue related to "Relative Layout" - android

Hi I'm making my first android program 'a calculator'. I was using the relative layout instead linear layout and I found some problems when it running it in the emulator.
1) the frame has not centered in the screen.
2) Once it is in the landscape mode, the numbers again goes to left side instead of centering it.
I tried many ways but still the problem remains same.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="#+id/textView"
android:background="#fbf8c9"
android:editable="true"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/button13"
android:layout_alignEnd="#+id/button13"
android:layout_marginTop="63dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:id="#+id/button"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
android:id="#+id/button2"
android:layout_above="#+id/button5"
android:layout_toRightOf="#+id/button"
android:layout_toEndOf="#+id/button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
android:id="#+id/button3"
android:layout_alignBottom="#+id/button2"
android:layout_toRightOf="#+id/button2"
android:layout_toEndOf="#+id/button2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4"
android:id="#+id/button4"
android:layout_below="#+id/button"
android:layout_alignLeft="#+id/button"
android:layout_alignStart="#+id/button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5"
android:id="#+id/button5"
android:layout_above="#+id/button8"
android:layout_toLeftOf="#+id/button3"
android:layout_toStartOf="#+id/button3" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6"
android:id="#+id/button6"
android:layout_below="#+id/button3"
android:layout_toRightOf="#+id/button2"
android:layout_toEndOf="#+id/button2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="7"
android:id="#+id/button7"
android:layout_below="#+id/button4"
android:layout_alignLeft="#+id/button4"
android:layout_alignStart="#+id/button4" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8"
android:id="#+id/button8"
android:layout_below="#+id/button4"
android:layout_toLeftOf="#+id/button6"
android:layout_toStartOf="#+id/button6" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="9"
android:id="#+id/button9"
android:layout_alignBottom="#+id/button8"
android:layout_toRightOf="#+id/button8"
android:layout_toEndOf="#+id/button8" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:id="#+id/button10"
android:layout_alignTop="#+id/button12"
android:layout_toLeftOf="#+id/button12"
android:layout_toStartOf="#+id/button12" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:id="#+id/button11"
android:layout_alignTop="#+id/button10"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:id="#+id/button12"
android:layout_below="#+id/button8"
android:layout_alignRight="#+id/button9"
android:layout_alignEnd="#+id/button9" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="*"
android:id="#+id/button13"
android:layout_toRightOf="#+id/button3"
android:layout_alignTop="#+id/button3"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/"
android:id="#+id/button14"
android:layout_below="#+id/button3"
android:layout_toRightOf="#+id/button6"
android:layout_alignTop="#+id/button6" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10"
android:id="#+id/button15"
android:layout_toRightOf="#+id/button9"
android:layout_alignTop="#+id/button9" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="20"
android:id="#+id/button16"
android:layout_alignTop="#+id/button12"
android:layout_toRightOf="#+id/button12"
android:layout_toEndOf="#+id/button12" />
</RelativeLayout>
</RelativeLayout>
please someone kindly help me in solving this issue..

Try the following.
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="#+id/textView"
android:background="#fbf8c9"
android:editable="true"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/button13"
android:layout_alignEnd="#+id/button13"
android:layout_marginTop="63dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:id="#+id/button"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
android:id="#+id/button2"
android:layout_above="#+id/button5"
android:layout_toRightOf="#+id/button"
android:layout_toEndOf="#+id/button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
android:id="#+id/button3"
android:layout_alignBottom="#+id/button2"
android:layout_toRightOf="#+id/button2"
android:layout_toEndOf="#+id/button2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4"
android:id="#+id/button4"
android:layout_below="#+id/button"
android:layout_alignLeft="#+id/button"
android:layout_alignStart="#+id/button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5"
android:id="#+id/button5"
android:layout_above="#+id/button8"
android:layout_toLeftOf="#+id/button3"
android:layout_toStartOf="#+id/button3" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6"
android:id="#+id/button6"
android:layout_below="#+id/button3"
android:layout_toRightOf="#+id/button2"
android:layout_toEndOf="#+id/button2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="7"
android:id="#+id/button7"
android:layout_below="#+id/button4"
android:layout_alignLeft="#+id/button4"
android:layout_alignStart="#+id/button4" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8"
android:id="#+id/button8"
android:layout_below="#+id/button4"
android:layout_toLeftOf="#+id/button6"
android:layout_toStartOf="#+id/button6" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="9"
android:id="#+id/button9"
android:layout_alignBottom="#+id/button8"
android:layout_toRightOf="#+id/button8"
android:layout_toEndOf="#+id/button8" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:id="#+id/button10"
android:layout_alignTop="#+id/button12"
android:layout_toLeftOf="#+id/button12"
android:layout_toStartOf="#+id/button12" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:id="#+id/button11"
android:layout_alignTop="#+id/button10"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:id="#+id/button12"
android:layout_below="#+id/button8"
android:layout_alignRight="#+id/button9"
android:layout_alignEnd="#+id/button9" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="*"
android:id="#+id/button13"
android:layout_toRightOf="#+id/button3"
android:layout_alignTop="#+id/button3"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/"
android:id="#+id/button14"
android:layout_below="#+id/button3"
android:layout_toRightOf="#+id/button6"
android:layout_alignTop="#+id/button6" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10"
android:id="#+id/button15"
android:layout_toRightOf="#+id/button9"
android:layout_alignTop="#+id/button9" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="20"
android:id="#+id/button16"
android:layout_alignTop="#+id/button12"
android:layout_toRightOf="#+id/button12"
android:layout_toEndOf="#+id/button12" />
</RelativeLayout>

Try this in your xml:
android:layout_centerInParent="true"
android:gravity="center"
android:layout_gravity="center"

this is common issue in RelativeLayout you must be use LinearLayout

Related

swipe across button without finger leaving the screen

I am making this phone dialer app for blind people that say the number that gets pressed and I want them to be able to swipe across the all buttons without their finger leaving the screen. When they swipe the number it only get pronounced and when they release the number it gets typed. I tried on the touch listener and swipe motion and it's not working. What I should do to make this work?
Here is my XML:
<Button
android:text="call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:id="#+id/button10"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:text="playback"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button11"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_above="#+id/button10"
android:layout_below="#+id/button4" />
<Button
android:text="#"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/button10"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:id="#+id/buttonhash" />
<Button
android:text="9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/buttonhash"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:id="#+id/button9" />
<Button
android:text="*"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/buttonastrike"
android:layout_alignBaseline="#+id/button0"
android:layout_alignBottom="#+id/button0"
android:layout_alignLeft="#+id/button7"
android:layout_alignStart="#+id/button7" />
<Button
android:text="4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button4"
android:layout_below="#+id/button1"
android:layout_alignLeft="#+id/button7"
android:layout_alignStart="#+id/button7"
android:layout_toLeftOf="#+id/button5"
android:layout_toStartOf="#+id/button5" />
<Button
android:text="7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button7"
android:layout_alignBaseline="#+id/button8"
android:layout_alignBottom="#+id/button8"
android:layout_toRightOf="#+id/button11"
android:layout_toLeftOf="#+id/button5"
android:layout_toStartOf="#+id/button5" />
<Button
android:text="delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button15"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_above="#+id/button11"
android:layout_alignTop="#+id/button1" />
<EditText
android:focusable="false"
android:focusableInTouchMode="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text=""
android:ems="10"
android:id="#+id/editText"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:text="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button1"
android:layout_alignBaseline="#+id/button2"
android:layout_alignBottom="#+id/button2"
android:layout_alignLeft="#+id/button4"
android:layout_alignStart="#+id/button4"
android:layout_toLeftOf="#+id/button5"
android:layout_toStartOf="#+id/button5" />
<Button
android:text="6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button6"
android:layout_above="#+id/button9"
android:layout_alignLeft="#+id/button9"
android:layout_alignStart="#+id/button9" />
<Button
android:text="5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button5"
android:layout_alignBaseline="#+id/button4"
android:layout_alignBottom="#+id/button4"
android:layout_toLeftOf="#+id/button9"
android:layout_toStartOf="#+id/button9" />
<Button
android:text="8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button8"
android:layout_alignBaseline="#+id/button9"
android:layout_alignBottom="#+id/button9"
android:layout_alignLeft="#+id/button5"
android:layout_alignStart="#+id/button5" />
<Button
android:text="2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button2"
android:layout_alignBaseline="#+id/button3"
android:layout_alignBottom="#+id/button3"
android:layout_alignLeft="#+id/button5"
android:layout_alignStart="#+id/button5" />
<Button
android:text="0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button0"
android:layout_alignBaseline="#+id/buttonhash"
android:layout_alignBottom="#+id/buttonhash"
android:layout_alignLeft="#+id/button8"
android:layout_alignStart="#+id/button8" />
<Button
android:text="3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button3"
android:layout_above="#+id/button6"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />

Relative layout doesn't properly display as expected in Landscape view

Hi I'm making my first android program 'a calculator'. I was using the relative layout instead linear layout and I found some problems when it running it in the emulator.
1) the frame has not centered in the screen. 2) Once it is in the landscape mode, the numbers again goes to left side instead of centering it.
I tried many ways but still the problem remains same.
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="#+id/textView2"
android:background="#fbf8c9"
android:editable="true"
android:layout_marginTop="20dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:id="#+id/button"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:onClick="buttonOnClick" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
android:id="#+id/button2"
android:layout_above="#+id/button5"
android:layout_toRightOf="#+id/button"
android:layout_toEndOf="#+id/button"
android:onClick="buttonOnClick" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
android:id="#+id/button3"
android:layout_alignBottom="#+id/button2"
android:layout_toRightOf="#+id/button2"
android:layout_toEndOf="#+id/button2"
android:onClick="buttonOnClick" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4"
android:id="#+id/button4"
android:layout_below="#+id/button"
android:layout_alignLeft="#+id/button"
android:layout_alignStart="#+id/button"
android:onClick="buttonOnClick" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5"
android:id="#+id/button5"
android:layout_above="#+id/button8"
android:layout_toLeftOf="#+id/button3"
android:layout_toStartOf="#+id/button3"
android:onClick="buttonOnClick" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6"
android:id="#+id/button6"
android:layout_below="#+id/button3"
android:layout_toRightOf="#+id/button2"
android:layout_toEndOf="#+id/button2"
android:onClick="buttonOnClick" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="7"
android:id="#+id/button7"
android:layout_below="#+id/button4"
android:layout_alignLeft="#+id/button4"
android:layout_alignStart="#+id/button4"
android:onClick="buttonOnClick" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8"
android:id="#+id/button8"
android:layout_below="#+id/button4"
android:layout_toLeftOf="#+id/button6"
android:layout_toStartOf="#+id/button6"
android:onClick="buttonOnClick" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="9"
android:id="#+id/button9"
android:layout_alignBottom="#+id/button8"
android:layout_toRightOf="#+id/button8"
android:layout_toEndOf="#+id/button8"
android:onClick="buttonOnClick" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:id="#+id/button10"
android:layout_alignTop="#+id/button12"
android:layout_toLeftOf="#+id/button12"
android:layout_toStartOf="#+id/button12"
android:onClick="buttonOnClick" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:id="#+id/button11"
android:layout_alignTop="#+id/button12"
android:layout_toRightOf="#+id/button12"
android:layout_toEndOf="#+id/button12"
android:onClick="buttonOnClick" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="="
android:id="#+id/button12"
android:layout_below="#+id/button8"
android:layout_alignRight="#+id/button9"
android:layout_alignEnd="#+id/button9"
android:onClick="buttonOnClick"
android:background="#dcfa82" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="*"
android:id="#+id/button13"
android:layout_toRightOf="#+id/button3"
android:layout_alignTop="#+id/button3"
android:onClick="buttonOnClick" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/"
android:id="#+id/button14"
android:layout_below="#+id/button3"
android:layout_toRightOf="#+id/button6"
android:layout_alignTop="#+id/button6"
android:onClick="buttonOnClick" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:id="#+id/button15"
android:layout_toRightOf="#+id/button9"
android:layout_alignTop="#+id/button9"
android:onClick="buttonOnClick" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AC"
android:id="#+id/button16"
android:layout_alignTop="#+id/button10"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:onClick="buttonOnClick" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="#+id/textView1"
android:background="#fbf8c9"
android:editable="true"
android:layout_marginTop="10dp"
android:layout_below="#+id/textView2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
</RelativeLayout>
please someone kindly help me in solving this issue..
I would suggest wrapping all the buttons in a View which itself can be centered in the RelativeLayout, such as a TableLayout. Here is a LinearLayout approach since you really only need the button-grid centered in a RelativeLayout. You can get all the buttons to fill the screen (like in the third photo) in a TableLayout using android:stretchColumns="*".
<?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">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView"
android:background="#fbf8c9"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fbf8c9"
android:layout_marginTop="10dp"
android:id="#+id/textView2"/>
<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent">
<TableLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp">
<TableRow>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:id="#+id/button"
android:onClick="buttonOnClick"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
android:id="#+id/button2"
android:onClick="buttonOnClick"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
android:id="#+id/button3"
android:onClick="buttonOnClick"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="*"
android:id="#+id/button13"
android:onClick="buttonOnClick"/>
</TableRow>
<TableRow>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4"
android:id="#+id/button4"
android:onClick="buttonOnClick"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5"
android:id="#+id/button5"
android:onClick="buttonOnClick"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6"
android:id="#+id/button6"
android:onClick="buttonOnClick"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/"
android:id="#+id/button14"
android:onClick="buttonOnClick"/>
</TableRow>
<TableRow>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="7"
android:id="#+id/button7"
android:onClick="buttonOnClick"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8"
android:id="#+id/button8"
android:onClick="buttonOnClick"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="9"
android:id="#+id/button9"
android:onClick="buttonOnClick"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:id="#+id/button15"
android:onClick="buttonOnClick"/>
</TableRow>
<TableRow>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AC"
android:id="#+id/button16"
android:onClick="buttonOnClick"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="="
android:id="#+id/button12"
android:onClick="buttonOnClick"
android:background="#dcfa82"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:id="#+id/button10"
android:onClick="buttonOnClick"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:id="#+id/button11"
android:onClick="buttonOnClick"/>
</TableRow>
</TableLayout>
</RelativeLayout>
</LinearLayout>
How about this?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#fbf8c9"
android:editable="true"
android:text="123243"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_marginTop="10dp"/>
<RelativeLayout
android:id="#+id/relLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="100dp">
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLefttOf="#+id/button2"
android:onClick="buttonOnClick"
android:text="1" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/button5"
android:layout_toEndOf="#+id/button"
android:layout_toRightOf="#+id/button"
android:onClick="buttonOnClick"
android:text="2" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/button2"
android:layout_toEndOf="#+id/button2"
android:layout_toRightOf="#+id/button2"
android:onClick="buttonOnClick"
android:text="3" />
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/button"
android:layout_alignStart="#+id/button"
android:layout_below="#+id/button"
android:onClick="buttonOnClick"
android:text="4" />
<Button
android:id="#+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/button8"
android:layout_toLeftOf="#+id/button3"
android:layout_toStartOf="#+id/button3"
android:onClick="buttonOnClick"
android:text="5" />
<Button
android:id="#+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button3"
android:layout_toEndOf="#+id/button2"
android:layout_toRightOf="#+id/button2"
android:onClick="buttonOnClick"
android:text="6" />
<Button
android:id="#+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/button4"
android:layout_alignStart="#+id/button4"
android:layout_below="#+id/button4"
android:onClick="buttonOnClick"
android:text="7" />
<Button
android:id="#+id/button8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button4"
android:layout_toLeftOf="#+id/button6"
android:layout_toStartOf="#+id/button6"
android:onClick="buttonOnClick"
android:text="8" />
<Button
android:id="#+id/button9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/button8"
android:layout_toEndOf="#+id/button8"
android:layout_toRightOf="#+id/button8"
android:onClick="buttonOnClick"
android:text="9" />
<Button
android:id="#+id/button10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/button12"
android:layout_toLeftOf="#+id/button12"
android:layout_toStartOf="#+id/button12"
android:onClick="buttonOnClick"
android:text="0" />
<Button
android:id="#+id/button11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/button12"
android:layout_toEndOf="#+id/button12"
android:layout_toRightOf="#+id/button12"
android:onClick="buttonOnClick"
android:text="+" />
<Button
android:id="#+id/button12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/button9"
android:layout_alignRight="#+id/button9"
android:layout_below="#+id/button8"
android:background="#dcfa82"
android:onClick="buttonOnClick"
android:text="=" />
<Button
android:id="#+id/button13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/button3"
android:layout_toRightOf="#+id/button3"
android:onClick="buttonOnClick"
android:text="*" />
<Button
android:id="#+id/button14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/button6"
android:layout_below="#+id/button3"
android:layout_toRightOf="#+id/button6"
android:onClick="buttonOnClick"
android:text="/" />
<Button
android:id="#+id/button15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/button9"
android:layout_toRightOf="#+id/button9"
android:onClick="buttonOnClick"
android:text="-" />
<Button
android:id="#+id/button16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignTop="#+id/button10"
android:onClick="buttonOnClick"
android:text="AC" />
</RelativeLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="50dp"
android:background="#fbf8c9"
android:editable="true"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
Portrait:
Landscape:
Below code should work, but I don't suggest using RelativeLayout which causes slow performance compared to other ViewGroups. Also you should reference existing calculator apps and separate portrait and landscape into 2 different layouts.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true" >
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="10dp"
android:background="#fbf8c9"
android:editable="true"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/textView2"
android:layout_marginTop="10dp"
android:background="#fbf8c9"
android:editable="true"
android:textAppearance="?android:attr/textAppearanceLarge" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true">
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLefttOf="#+id/button2"
android:onClick="buttonOnClick"
android:text="1" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/button5"
android:layout_toEndOf="#+id/button"
android:layout_toRightOf="#+id/button"
android:onClick="buttonOnClick"
android:text="2" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/button2"
android:layout_toEndOf="#+id/button2"
android:layout_toRightOf="#+id/button2"
android:onClick="buttonOnClick"
android:text="3" />
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/button"
android:layout_alignStart="#+id/button"
android:layout_below="#+id/button"
android:onClick="buttonOnClick"
android:text="4" />
<Button
android:id="#+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/button8"
android:layout_toLeftOf="#+id/button3"
android:layout_toStartOf="#+id/button3"
android:onClick="buttonOnClick"
android:text="5" />
<Button
android:id="#+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button3"
android:layout_toEndOf="#+id/button2"
android:layout_toRightOf="#+id/button2"
android:onClick="buttonOnClick"
android:text="6" />
<Button
android:id="#+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/button4"
android:layout_alignStart="#+id/button4"
android:layout_below="#+id/button4"
android:onClick="buttonOnClick"
android:text="7" />
<Button
android:id="#+id/button8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button4"
android:layout_toLeftOf="#+id/button6"
android:layout_toStartOf="#+id/button6"
android:onClick="buttonOnClick"
android:text="8" />
<Button
android:id="#+id/button9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/button8"
android:layout_toEndOf="#+id/button8"
android:layout_toRightOf="#+id/button8"
android:onClick="buttonOnClick"
android:text="9" />
<Button
android:id="#+id/button10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/button12"
android:layout_toLeftOf="#+id/button12"
android:layout_toStartOf="#+id/button12"
android:onClick="buttonOnClick"
android:text="0" />
<Button
android:id="#+id/button11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/button12"
android:layout_toEndOf="#+id/button12"
android:layout_toRightOf="#+id/button12"
android:onClick="buttonOnClick"
android:text="+" />
<Button
android:id="#+id/button12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/button9"
android:layout_alignRight="#+id/button9"
android:layout_below="#+id/button8"
android:background="#dcfa82"
android:onClick="buttonOnClick"
android:text="=" />
<Button
android:id="#+id/button13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/button3"
android:layout_toRightOf="#+id/button3"
android:onClick="buttonOnClick"
android:text="*" />
<Button
android:id="#+id/button14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/button6"
android:layout_below="#+id/button3"
android:layout_toRightOf="#+id/button6"
android:onClick="buttonOnClick"
android:text="/" />
<Button
android:id="#+id/button15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/button9"
android:layout_toRightOf="#+id/button9"
android:onClick="buttonOnClick"
android:text="-" />
<Button
android:id="#+id/button16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignTop="#+id/button10"
android:onClick="buttonOnClick"
android:text="AC" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>

How to make child TextViews stay in position in Relative Layout?

Here I have a RelativeLayout with TextViews, Spinners ect. The TextViews change according to the progress value of the respective Spinner. I want my TextViews to remain in the current position and not shift the match the length of the growing parents progress value.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Space
android:id="#+id/Space1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
<Space
android:id="#+id/Space2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/Space1" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="42dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="42dp"
android:layout_marginTop="50dp"
android:scaleType="fitXY"
android:src="#drawable/primaryneedsbg" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageView2"
android:layout_alignTop="#+id/imageView2"
android:layout_marginLeft="41dp"
android:layout_marginTop="79dp"
android:text="#string/housing"
android:textAppearance="?android:attr/textAppearanceLarge"
android:includeFontPadding="false"/>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/textView1"
android:layout_marginTop="26dp"
android:text="#string/debt"
android:textAppearance="?android:attr/textAppearanceLarge"
android:includeFontPadding="false" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView2"
android:layout_below="#+id/textView2"
android:layout_marginTop="25dp"
android:text="#string/child"
android:textAppearance="?android:attr/textAppearanceLarge"
android:includeFontPadding="false" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView3"
android:layout_below="#+id/textView3"
android:layout_marginTop="25dp"
android:text="#string/edu"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView4"
android:layout_below="#+id/textView4"
android:layout_marginTop="30dp"
android:text="#string/exp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView5"
android:layout_below="#+id/textView5"
android:layout_marginTop="25dp"
android:text="#string/special"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView6"
android:layout_below="#+id/textView6"
android:layout_marginTop="25dp"
android:text="#string/surv"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView1"
android:layout_marginLeft="176dp"
android:layout_toRightOf="#+id/textView1"
android:freezesText="true"
android:text="$0"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView2"
android:layout_alignBottom="#+id/textView2"
android:layout_alignParentStart="false"
android:layout_alignRight="#+id/textView8"
android:freezesText="true"
android:text="$0"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView3"
android:layout_alignBottom="#+id/textView3"
android:layout_alignLeft="#+id/textView9"
android:text="$0"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView4"
android:layout_alignBottom="#+id/textView4"
android:layout_alignLeft="#+id/textView10"
android:text="$0"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView5"
android:layout_alignBottom="#+id/textView5"
android:layout_alignLeft="#+id/textView11"
android:text="$0"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView6"
android:layout_alignBottom="#+id/textView6"
android:layout_alignLeft="#+id/textView12"
android:text="$0"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView7"
android:layout_alignBottom="#+id/textView7"
android:layout_alignLeft="#+id/textView13"
android:text="$0"
android:textAppearance="?android:attr/textAppearanceLarge" />
<SeekBar
android:id="#+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/textView2"
android:layout_toLeftOf="#+id/imageView1"
android:layout_toRightOf="#+id/button1" />
<Button
android:id="#+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView9"
android:layout_alignRight="#+id/imageView2"
android:layout_alignTop="#+id/button1"
android:layout_marginRight="219dp"
android:background="#null"
android:text="+"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignLeft="#+id/button2"
android:layout_alignTop="#+id/seekBar1"
android:layout_marginLeft="48dp"
android:scaleType="fitXY"
android:src="#drawable/cross" />
<Button
android:id="#+id/button4"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView2"
android:layout_alignRight="#+id/imageView2"
android:text="#string/Perm" />
<Button
android:id="#+id/Button01"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView9"
android:layout_alignBottom="#+id/textView9"
android:layout_alignLeft="#+id/button1"
android:background="#null"
android:text="-"
android:textSize="25dp"
android:textStyle="bold" />
<Button
android:id="#+id/Button04"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView10"
android:layout_alignBottom="#+id/textView10"
android:layout_toLeftOf="#+id/seekBar1"
android:background="#null"
android:text="-"
android:textSize="25dp"
android:textStyle="bold" />
<Button
android:id="#+id/Button06"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView14"
android:layout_alignBottom="#+id/textView14"
android:layout_toLeftOf="#+id/seekBar1"
android:background="#null"
android:text="-"
android:textSize="25dp"
android:textStyle="bold" />
<Button
android:id="#+id/Button05"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView13"
android:layout_alignBottom="#+id/textView13"
android:layout_alignLeft="#+id/Button06"
android:background="#null"
android:text="-"
android:textSize="25dp"
android:textStyle="bold" />
<Button
android:id="#+id/Button02"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView12"
android:layout_alignBottom="#+id/textView12"
android:layout_toLeftOf="#+id/seekBar1"
android:background="#null"
android:text="-"
android:textSize="25dp"
android:textStyle="bold" />
<Button
android:id="#+id/Button03"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView11"
android:layout_alignBottom="#+id/textView11"
android:layout_toRightOf="#+id/textView8"
android:background="#null"
android:textSize="25dp"
android:textStyle="bold" />
<SeekBar
android:id="#+id/seekBar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView9"
android:layout_alignLeft="#+id/seekBar1"
android:layout_alignRight="#+id/seekBar1" />
<SeekBar
android:id="#+id/SeekBar04"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/seekBar2"
android:layout_alignTop="#+id/textView10"
android:layout_toLeftOf="#+id/button2" />
<SeekBar
android:id="#+id/SeekBar03"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/SeekBar04"
android:layout_alignRight="#+id/SeekBar04"
android:layout_alignTop="#+id/textView11" />
<SeekBar
android:id="#+id/SeekBar02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/SeekBar03"
android:layout_alignTop="#+id/textView12"
android:layout_toLeftOf="#+id/button2" />
<SeekBar
android:id="#+id/SeekBar01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/SeekBar02"
android:layout_alignRight="#+id/SeekBar02"
android:layout_alignTop="#+id/textView13" />
<SeekBar
android:id="#+id/seekBar3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/Button06"
android:layout_alignLeft="#+id/SeekBar01"
android:layout_alignRight="#+id/SeekBar01" />
<Button
android:id="#+id/Button12"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/Button01"
android:layout_alignBottom="#+id/Button01"
android:layout_alignLeft="#+id/button2"
android:background="#null"
android:text="+"
android:textStyle="bold" />
<Button
android:id="#+id/Button11"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/Button04"
android:layout_alignBottom="#+id/Button04"
android:layout_alignLeft="#+id/Button12"
android:background="#null"
android:text="+"
android:textStyle="bold" />
<Button
android:id="#+id/Button07"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/Button08"
android:layout_alignTop="#+id/seekBar3"
android:background="#null"
android:text="+"
android:textStyle="bold" />
<Button
android:id="#+id/Button08"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/Button05"
android:layout_alignBottom="#+id/Button05"
android:layout_alignLeft="#+id/Button09"
android:background="#null"
android:text="+"
android:textStyle="bold" />
<Button
android:id="#+id/Button09"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/Button10"
android:layout_alignTop="#+id/SeekBar02"
android:background="#null"
android:text="+"
android:textStyle="bold" />
<Button
android:id="#+id/Button10"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/Button02"
android:layout_alignLeft="#+id/Button11"
android:background="#null"
android:text="+"
android:textStyle="bold" />
<ImageView
android:id="#+id/ImageView07"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignTop="#+id/textView9"
android:layout_toRightOf="#+id/Button12"
android:scaleType="fitXY"
android:src="#drawable/cross" />
<ImageView
android:id="#+id/ImageView06"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignBottom="#+id/textView10"
android:layout_alignLeft="#+id/ImageView07"
android:scaleType="fitXY"
android:src="#drawable/cross" />
<ImageView
android:id="#+id/ImageView05"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignTop="#+id/SeekBar03"
android:layout_toRightOf="#+id/Button10"
android:scaleType="fitXY"
android:src="#drawable/cross" />
<ImageView
android:id="#+id/ImageView04"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignBottom="#+id/Button02"
android:layout_alignLeft="#+id/ImageView05"
android:scaleType="fitXY"
android:src="#drawable/cross" />
<ImageView
android:id="#+id/ImageView03"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignBottom="#+id/textView13"
android:layout_alignLeft="#+id/ImageView04"
android:scaleType="fitXY"
android:src="#drawable/cross" />
<ImageView
android:id="#+id/ImageView02"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignBottom="#+id/seekBar3"
android:layout_alignLeft="#+id/ImageView03"
android:scaleType="fitXY"
android:src="#drawable/cross" />
<Button
android:id="#+id/Button16"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/SeekBar03"
android:layout_toLeftOf="#+id/button4"
android:text="Temporary" />
<Button
android:id="#+id/button3"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/button1"
android:layout_toLeftOf="#+id/button4"
android:text="Temporary" />
<Button
android:id="#+id/Button18"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView3"
android:layout_toLeftOf="#+id/button4"
android:text="Temporary" />
<Button
android:id="#+id/Button17"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/SeekBar04"
android:layout_toLeftOf="#+id/button4"
android:text="Temporary" />
<Button
android:id="#+id/Button15"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/Button02"
android:layout_toLeftOf="#+id/button4"
android:text="Temporary" />
<Button
android:id="#+id/Button14"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView7"
android:layout_alignLeft="#+id/Button15"
android:text="Temporary" />
<Button
android:id="#+id/Button13"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/Button05"
android:layout_toLeftOf="#+id/button4"
android:text="Temporary" />
<Button
android:id="#+id/Button23"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/Button17"
android:layout_alignRight="#+id/imageView2"
android:layout_alignTop="#+id/Button17"
android:text="#string/Perm" />
<Button
android:id="#+id/Button21"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/Button14"
android:layout_alignRight="#+id/imageView2"
android:layout_alignTop="#+id/Button15"
android:text="#string/Perm" />
<Button
android:id="#+id/Button24"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView3"
android:layout_alignRight="#+id/imageView2"
android:layout_alignTop="#+id/Button18"
android:text="#string/Perm" />
<Button
android:id="#+id/Button22"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/Button21"
android:layout_alignRight="#+id/imageView2"
android:layout_alignTop="#+id/Button16"
android:text="#string/Perm" />
<Button
android:id="#+id/Button20"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/Button14"
android:layout_alignBottom="#+id/Button14"
android:layout_alignLeft="#+id/Button21"
android:text="#string/Perm" />
<Button
android:id="#+id/Button19"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/Button13"
android:layout_toRightOf="#+id/Button13"
android:text="#string/Perm" />
<Button
android:id="#+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView8"
android:layout_alignBottom="#+id/textView8"
android:layout_marginLeft="182dp"
android:layout_toRightOf="#+id/Button03"
android:background="#null"
android:text="-"
android:textSize="25dp"
android:textStyle="bold" />
<Button
android:id="#+id/Button25"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/Button03"
android:layout_alignBottom="#+id/Button03"
android:layout_toLeftOf="#+id/SeekBar03"
android:background="#null"
android:text="-"
android:textSize="25dp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView7"
android:layout_below="#+id/Button07"
android:text="#string/permNeeds"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView15"
android:layout_below="#+id/textView15"
android:layout_marginTop="21dp"
android:text="#string/tempNeeds"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView16"
android:layout_below="#+id/textView16"
android:layout_marginTop="21dp"
android:text="#string/tNeeds:"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView15"
android:layout_alignBottom="#+id/textView15"
android:layout_alignLeft="#+id/textView14"
android:text="$0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<TextView
android:id="#+id/textView19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView17"
android:layout_alignLeft="#+id/textView18"
android:text="$0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<TextView
android:id="#+id/textView20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView17"
android:layout_alignLeft="#+id/textView19"
android:text="$0"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold" />
<TextView
android:id="#+id/textView21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/imageView2"
android:layout_toRightOf="#+id/imageView1"
android:text="#string/typeNeed"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView1"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:scaleType="fitXY"
android:src="#drawable/lifebar" />
<TextView
android:id="#+id/textView22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imageView3"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="#string/lifebar4"
android:textAppearance="?android:attr/textAppearanceLarge" />

My android layout changes each time i chose a different device in emulator even if they have approximately same size?

Here is my xml file
<RelativeLayout 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:paddingLeft="15dp"
android:paddingRight="15dp"
tools:context=".MainActivity" >
<TextView
android:id="#+id/ResultText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:textSize="20sp"
android:layout_marginTop="5dp"
android:background="#EEEEEE" />
<TextView
android:id="#+id/InputText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/ResultText"
android:layout_below="#+id/ResultText"
android:background="#BBBBBB"
android:gravity="right"
android:textColor="#FFFFFF"
android:layout_marginTop="4dp"
android:textSize="15sp" />
<Button
android:id="#+id/button5"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/button1"
android:layout_below="#+id/button1"
android:text="5" />
<Button
android:id="#+id/button7"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/button3"
android:layout_alignTop="#+id/button6"
android:text="7" />
<Button
android:id="#+id/button8"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/button4"
android:layout_alignTop="#+id/button7"
android:text="8" />
<Button
android:id="#+id/button9"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/button5"
android:layout_below="#+id/button5"
android:text="9" />
<Button
android:id="#+id/buttonMultiply"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/buttonDivide"
android:text="x" />
<Button
android:id="#+id/buttonSubtract"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/buttonAdd"
android:layout_alignBottom="#+id/buttonAdd"
android:layout_alignParentRight="true"
android:text="-" />
<Button
android:id="#+id/buttonDivide"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/button8"
android:layout_alignBottom="#+id/button8"
android:layout_alignLeft="#+id/buttonAdd"
android:text="/" />
<Button
android:id="#+id/buttonAdd"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/button4"
android:layout_alignBottom="#+id/button4"
android:layout_toLeftOf="#+id/buttonSubtract"
android:text="+" />
<Button
android:id="#+id/button4"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/button8"
android:layout_toLeftOf="#+id/buttonDivide"
android:text="4" />
<Button
android:id="#+id/button3"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/button7"
android:layout_toLeftOf="#+id/button8"
android:text="3" />
<Button
android:id="#+id/buttonDot"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/button0"
android:layout_alignBottom="#+id/button0"
android:layout_alignLeft="#+id/button7"
android:text="." />
<Button
android:id="#+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/button3"
android:layout_alignBottom="#+id/button3"
android:layout_toLeftOf="#+id/button3"
android:text="2" />
<Button
android:id="#+id/button6"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/button0"
android:layout_toLeftOf="#+id/button7"
android:text="6" />
<Button
android:id="#+id/button0"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/button9"
android:layout_alignBottom="#+id/button9"
android:layout_alignLeft="#+id/button6"
android:text="0" />
<Button
android:id="#+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/InputText"
android:layout_marginTop="26dp"
android:layout_toLeftOf="#+id/button2"
android:text="1" />
<Button
android:id="#+id/buttonEqual"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/buttonDot"
android:layout_alignBottom="#+id/buttonDot"
android:layout_alignRight="#+id/buttonMultiply"
android:layout_toRightOf="#+id/button8"
android:text="=" />
<Button
android:id="#+id/buttonDel"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/buttonDot"
android:layout_toRightOf="#+id/buttonDot"
android:text="del" />
<Button
android:id="#+id/buttonSin"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/button9"
android:layout_below="#+id/button9"
android:text="sin" />
<Button
android:id="#+id/buttonCos"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/button0"
android:layout_alignTop="#+id/buttonSin"
android:text="cos" />
<Button
android:id="#+id/buttonTan"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/buttonDot"
android:layout_alignTop="#+id/buttonCos"
android:text="tan" />
<Button
android:id="#+id/buttonCot"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/buttonSec"
android:text="cot" />
<Button
android:id="#+id/buttonSec"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/buttonCosec"
android:layout_alignBottom="#+id/buttonCosec"
android:layout_toLeftOf="#+id/buttonCot"
android:text="sec" />
<Button
android:id="#+id/buttonCosec"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/buttonTan"
android:layout_alignBottom="#+id/buttonTan"
android:layout_toLeftOf="#+id/buttonSec"
android:layout_marginLeft="1dp"
android:text="csec" />
<Button
android:id="#+id/buttonPow"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/buttonSin"
android:layout_below="#+id/buttonSin"
android:layout_alignRight="#+id/buttonSin"
android:gravity="left"
android:textSize="10sp"
android:text="yX" />
<Button
android:id="#+id/buttonLog10"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/buttonPow"
android:layout_toRightOf="#+id/buttonPow"
android:text="log" />
<Button
android:id="#+id/buttonLoge"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/buttonLog10"
android:layout_alignBottom="#+id/buttonLog10"
android:layout_toRightOf="#+id/buttonLog10"
android:text="ln" />
<Button
android:id="#+id/buttonSquare"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/buttonLoge"
android:layout_toRightOf="#+id/buttonLoge"
android:text="sqr" />
<Button
android:id="#+id/buttonSqrt"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/buttonSquare"
android:layout_toRightOf="#+id/buttonSquare"
android:text="sqrt" />
<Button
android:id="#+id/buttonFactorial"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/buttonSqrt"
android:text="x!" />
<Button
android:id="#+id/buttonSinh"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/buttonPow"
android:layout_below="#+id/buttonPow"
android:layout_toLeftOf="#+id/buttonLoge"
android:text="sinh" />
<Button
android:id="#+id/buttonCosh"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/buttonSinh"
android:layout_alignBottom="#+id/buttonSinh"
android:layout_alignLeft="#+id/buttonLoge"
android:layout_toLeftOf="#+id/buttonSqrt"
android:text="cosh" />
<Button
android:id="#+id/buttonTanh"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/buttonSqrt"
android:layout_alignRight="#+id/buttonFactorial"
android:layout_alignTop="#+id/buttonCosh"
android:text="tanh" />
</RelativeLayout>
here are some screen shots:
As you can see the left portion is not filled completely it is on a 4.65 inch xhdpi screen
On a 4 inch hdpi screen its perfect covering full width and full height
Basically, what Ben Pearson suggested, you can use TableLayout and several TableRow layouts. For example, a single row layout XML might look like this:
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/button5"
style="?android:attr/buttonStyleSmall"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="5" />
<Button
android:id="#+id/button6"
style="?android:attr/buttonStyleSmall"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="6" />
<Button
android:id="#+id/button7"
style="?android:attr/buttonStyleSmall"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="7" />
<Button
android:id="#+id/button8"
style="?android:attr/buttonStyleSmall"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="8" />
<Button
android:id="#+id/buttonDivide"
style="?android:attr/buttonStyleSmall"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="/" />
<Button
android:id="#+id/buttonMultiply"
style="?android:attr/buttonStyleSmall"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="x" />
</TableRow>
Note that since TableRow is a subclass of LinearLayout, it understands the layout_weight attribute on its children. Set the layout_width to 0dp and layout_weight to 1 on each button (or 2, for some buttons).

Named Buttons in Android

I am trying to create a button in an Android layout with name "=" and Eclipse says:
It is not acceptable.
How can I create a button with name "=" or "1" etc?
here is the buttons:
Here is xml code
<RelativeLayout 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" >
<Button
android:id="#+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="29dp"
android:layout_marginTop="98dp"
android:text="7" />
<Button
android:id="#+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/button1"
android:layout_toRightOf="#+id/button1"
android:text="8" />
<Button
android:id="#+id/button3"
style="?android:attr/buttonStyleSmall"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/button2"
android:layout_toRightOf="#+id/button2"
android:text="9" />
<Button
android:id="#+id/button4"
style="?android:attr/buttonStyleSmall"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/button1"
android:layout_below="#+id/button1"
android:text="4" />
<Button
android:id="#+id/button5"
style="?android:attr/buttonStyleSmall"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/button4"
android:layout_alignLeft="#+id/button2"
android:text="5" />
<Button
android:id="#+id/button6"
style="?android:attr/buttonStyleSmall"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/button5"
android:layout_toRightOf="#+id/button2"
android:text="6" />
<Button
android:id="#+id/button7"
style="?android:attr/buttonStyleSmall"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/button4"
android:layout_below="#+id/button4"
android:text="1" />
<Button
android:id="#+id/button8"
style="?android:attr/buttonStyleSmall"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/button7"
android:layout_toRightOf="#+id/button4"
android:text="2" />
<Button
android:id="#+id/button9"
style="?android:attr/buttonStyleSmall"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/button8"
android:layout_toRightOf="#+id/button5"
android:text="3" />
<Button
android:id="#+id/button10"
style="?android:attr/buttonStyleSmall"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/button7"
android:layout_below="#+id/button7"
android:text="." />
<Button
android:id="#+id/button11"
style="?android:attr/buttonStyleSmall"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/button10"
android:layout_toRightOf="#+id/button7"
android:text="0" />
<Button
android:id="#+id/button12"
style="?android:attr/buttonStyleSmall"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/button11"
android:layout_alignBottom="#+id/button11"
android:layout_alignLeft="#+id/button9"
android:text="=" />
<Button
android:id="#+id/button13"
style="?android:attr/buttonStyleSmall"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_above="#+id/button6"
android:layout_toRightOf="#+id/button3"
android:text="/" />
<Button
android:id="#+id/button14"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/button6"
android:layout_alignBottom="#+id/button6"
android:layout_alignRight="#+id/button13"
android:layout_toRightOf="#+id/button3"
android:freezesText="true"
android:text="-" />
<Button
android:id="#+id/button15"
style="?android:attr/buttonStyleSmall"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/button9"
android:layout_alignBottom="#+id/button9"
android:layout_toRightOf="#+id/button6"
android:text="+" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/button1"
android:layout_alignParentTop="true"
android:layout_marginTop="70dp"
android:text="#string/hello_world"
tools:context=".MainActivity" />
</RelativeLayout>
You are confusing the name of the button with the text shown on the button. So please give your button the name "buttonEquals" (or the like), and just set its text (or label) to "=".
Button mybtn = (Button)findViewById(R.id.YOURBUTTONID);
mybtn.setText("=");

Categories

Resources