I have a big tablelayout with 28 buttons. (Making a calculator)
Anyway when one of these buttons gets clicked the gravity of that button and even some buttons in the same row changes so that the text is aligned to the left end.
I have no idea and it´s starting to make me a bit crazy.
Here´s the layout.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/TableLayout1"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="10dp"
android:background="#DDD"
android:orientation="vertical" >
<ScrollView
android:background="#DDD"
android:id="#+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:id="#+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textViewInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000" />
<TextView
android:id="#+id/textViewResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="5dp"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
<TableLayout
android:id="#+id/TableLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<TableRow
android:id="#+id/TableRow07"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:gravity="center_vertical"
android:weightSum="5" >
<Button
android:id="#+id/Button06"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_root"
android:textColor="#android:color/primary_text_light"
android:gravity="center" />
<Button
android:id="#+id/bAsin"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:textColor="#android:color/primary_text_light"
android:gravity="center" />
<Button
android:id="#+id/bAcos"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:gravity="center"/>
<Button
android:id="#+id/batan"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.4"
android:gravity="center" />
</TableRow>
<TableRow
android:id="#+id/TableRow06"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:weightSum="5" >
<Button
android:id="#+id/Button04"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_pi"
android:textColor="#android:color/primary_text_light"
android:gravity="center" />
<Button
android:id="#+id/Button03"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="#string/_sin"
android:textColor="#android:color/primary_text_light"
android:gravity="center"/>
<Button
android:id="#+id/Button02"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_cos"
android:gravity="center" />
<Button
android:id="#+id/Button01"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.4"
android:text="#string/_tan"
android:gravity="center"/>
</TableRow>
<TableRow
android:id="#+id/TableRow05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:weightSum="5" >
<Button
android:id="#+id/bPow"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_pow"
android:textColor="#android:color/primary_text_light"
android:gravity="center"/>
<Button
android:id="#+id/blpar"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="#string/_lpar"
android:textColor="#android:color/primary_text_light"
android:gravity="center"/>
<Button
android:id="#+id/brpar"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_rpar"
android:gravity="center" />
<Button
android:id="#+id/bdiv"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.4"
android:text="#string/_div"
android:gravity="center" />
</TableRow>
<TableRow
android:id="#+id/TableRow04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:weightSum="5" >
<Button
android:id="#+id/b7"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_7"
android:textColor="#android:color/primary_text_light"
android:gravity="center"/>
<Button
android:id="#+id/b8"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="#string/_8"
android:textColor="#android:color/primary_text_light"
android:gravity="center"/>
<Button
android:id="#+id/b9"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_9"
android:gravity="center" />
<Button
android:id="#+id/bmul"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.4"
android:text="#string/_times"
android:textStyle="bold"
android:gravity="center" />
</TableRow>
<TableRow
android:id="#+id/TableRow03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:weightSum="5" >
<Button
android:id="#+id/b4"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_4"
android:textColor="#android:color/primary_text_light"
android:gravity="center" />
<Button
android:id="#+id/b5"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="#string/_5"
android:textColor="#android:color/primary_text_light"
android:gravity="center" />
<Button
android:id="#+id/b6"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_6"
android:gravity="center" />
<Button
android:id="#+id/bsub"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.4"
android:text="#string/_minus"
android:gravity="center"/>
</TableRow>
<TableRow
android:id="#+id/TableRow02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:weightSum="5" >
<Button
android:id="#+id/b1"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_1"
android:textColor="#android:color/primary_text_light"
android:gravity="center"/>
<Button
android:id="#+id/b2"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="#string/_2"
android:textColor="#android:color/primary_text_light"
android:gravity="center" />
<Button
android:id="#+id/b3"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_3"
android:gravity="center"/>
<Button
android:id="#+id/badd"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.4"
android:text="#string/_plus"
android:gravity="center"/>
</TableRow>
<TableRow
android:id="#+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:weightSum="5" >
<Button
android:id="#+id/b0"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_0"
android:textColor="#android:color/primary_text_light"
android:gravity="center"/>
<Button
android:id="#+id/bPoint"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:gravity="center"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="#string/dot"
android:textColor="#android:color/primary_text_light" />
<Button
android:id="#+id/bClear"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:gravity="center"
android:text="#string/clear" />
<Button
android:id="#+id/bEnter"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.4"
android:text="#string/enter" />
</TableRow>
</TableLayout>
</RelativeLayout>
Anyone got any idea of whats wrong? I´m not touching the buttons through code, just checking the id to know which button was clicked. Nothing more, not changing gravity there or anything.
EDIT
oh yeah right, i forgot the white style. I´m pretty sure thats not it since i trie I dont know why it´s behaving like this.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape android:shape="rectangle">
<corners android:radius="0dp"/>
<gradient android:startColor="#a8a8a8" android:endColor="#c8c8c8" android:angle="270"></gradient>
</shape>
</item>
<item android:state_focused="true" >
<shape>
<solid android:color="#DDDDDD" />
</shape>
</item>
<item>
<shape android:shape="rectangle" >
<corners android:radius="0dp"/>
<solid android:color="#c8c8c8"/>
</shape>
</item>
</selector>
I know I'm 5 years late to the party but this is still a fairly inexplicable bug even in Oreo.
For me it only happens sometimes (I have another app with the exact same layout in a "fragment A and fragment B side by side on the same screen situation" where it's not an issue).
When I throw the table layout onto a single screen and click a button (which updates a TextView above the table), the gravity of the button changes itself and won't change back.
My solution (and this is definitely a hack but it works), is to wrap the TableLayout in a FrameLayout and the TextView I update in it's own FrameLayout. This must force Android to skip trying to relayout the table because they are independent frames.
Related
I'm having trouble to make my ImageView fit the background width
see :
here is the xml
<?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="#drawable/bg"
android:paddingLeft="8dp" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="150dp"
android:orientation="horizontal" >
<Button
android:id="#+id/button1"
android:layout_width="80dip"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:drawableTop="#drawable/actualites"
android:onClick="onClickactu"
android:text="Actualités"
android:textColor="#fff"
android:textSize="12sp"
android:textStyle="bold"
android:typeface="normal"
android:background="#null"
/>
<Button
android:id="#+id/button2"
android:layout_width="80dip"
android:layout_height="wrap_content"
android:drawableTop="#drawable/agenda"
android:text="Agenda"
android:onClick="onClickagend"
android:textColor="#fff"
android:textSize="12sp"
android:textStyle="bold"
android:typeface="normal"
android:layout_marginRight="15dp"
android:background="#null" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="#drawable/municipalite"
android:onClick="onClickmuni"
android:gravity="center_vertical|center_horizontal|bottom"
android:text="Municipalité"
android:textColor="#fff"
android:textSize="12sp"
android:textStyle="bold"
android:typeface="normal"
android:background="#null" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/linearLayout1"
android:layout_below="#+id/linearLayout1"
android:orientation="horizontal"
android:layout_marginTop="15dp" >
<Button
android:id="#+id/button4"
android:layout_width="80dip"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:background="#null"
android:drawableTop="#drawable/jeunesse"
android:text="Jeunesse"
android:onClick="onClickjeun"
android:textColor="#fff"
android:textSize="12sp"
android:textStyle="bold"
android:typeface="normal" />
<Button
android:id="#+id/button5"
android:layout_width="80dip"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:background="#null"
android:drawableTop="#drawable/sante"
android:onClick="onClicksant"
android:text="Santé"
android:textColor="#fff"
android:textSize="12sp"
android:textStyle="bold"
android:typeface="normal" />
<Button
android:id="#+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:drawableTop="#drawable/action_sociale"
android:text="Action Sociale"
android:onClick="onClicksoci"
android:textColor="#fff"
android:textSize="12sp"
android:textStyle="bold"
android:typeface="normal" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/linearLayout2"
android:layout_below="#+id/linearLayout2"
android:orientation="horizontal"
android:layout_marginTop="15dp" >
<Button
android:id="#+id/button10"
android:layout_width="80dip"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:background="#null"
android:drawableTop="#drawable/commerces"
android:text="Commerces"
android:onClick="onClickcomm"
android:textColor="#fff"
android:textSize="12sp"
android:textStyle="bold"
android:typeface="normal" />
<Button
android:id="#+id/button9"
android:layout_width="80dip"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:background="#null"
android:drawableTop="#drawable/associations"
android:text="Associations"
android:onClick="onClickasso"
android:textColor="#fff"
android:textSize="12sp"
android:textStyle="bold"
android:typeface="normal" />
<Button
android:id="#+id/button8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:drawableTop="#drawable/cadre_vie"
android:text="Cadre de vie"
android:onClick="onClickvie"
android:textColor="#fff"
android:textSize="12sp"
android:textStyle="bold"
android:typeface="normal" />
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="36dp"
android:gravity="center"
android:src="#drawable/ville_daudaces" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:scaleType="fillXY"
android:src="#drawable/barand" />
</RelativeLayout>
Thanks
Just remove the padding in the parent RelativeLayout ie android:paddingLeft="8dp".Remove this line
Change the value of android:layout_width from wrap_content to match_parent as below
android:layout_width="match_parent"
As goonerdroid said, remove the android:paddingLeft attribute from parent RelativeLayout or set it to 0dip...this android:paddingLeft="8dp" causing the extra space to the left of ImageView.
Remove this line: android:paddingLeft="8dp"
Like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bg">
I have RelativeLayout which has other elements such as imageview, textview inside it. When i run the app with small screen size (Galaxy S2) it is displayed as image 1. But when it runs on a larger screen (Nexus 7) it is displayed as in image 2. I do not want to enlarge the image for larger screens and i want it to keep certain sizes i set (see .xml). But how i can make it appears at the center on large screens (as in image 3).
Thank you for suggestions.
.xml file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ll1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/stainbck"
android:orientation="vertical"
android:padding="25dp" >
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Customized Templates"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#eaeaea" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/btn1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_weight="1"
android:text="1" />
<Button
android:id="#+id/btn2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/btn1"
android:layout_weight="1"
android:text="2" />
<Button
android:id="#+id/btn3"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/btn2"
android:layout_weight="1"
android:text="3" />
<Button
android:id="#+id/btn4"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="4" />
</LinearLayout>
<LinearLayout
android:id="#+id/relative2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/btn5"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_weight="1"
android:text="5" />
<Button
android:id="#+id/btn6"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_weight="1"
android:text="6" />
<Button
android:id="#+id/btn7"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/btn6"
android:layout_weight="1"
android:text="7" />
<Button
android:id="#+id/btn8"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/btn7"
android:layout_weight="1"
android:text="8" />
</LinearLayout>
<RelativeLayout
android:id="#+id/relative"
android:layout_width="265dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:gravity="center"
android:longClickable="true" >
<ImageView
android:id="#+id/blankcard"
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:adjustViewBounds="true" />
<TextView
android:id="#+id/crdCompany"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Company"
android:textColor="#20526d"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="#+id/crdWebsite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="16dp"
android:text="website"
android:textColor="#20526d"
android:textSize="9sp"
android:textStyle="bold" />
<TextView
android:id="#+id/crdAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/crdPhone"
android:layout_alignParentLeft="true"
android:text="address"
android:textColor="#20526d"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:id="#+id/crdEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/crdWebsite"
android:layout_alignBottom="#+id/crdWebsite"
android:layout_alignParentRight="true"
android:text="email"
android:textColor="#20526d"
android:textSize="9sp"
android:textStyle="bold" />
<TextView
android:id="#+id/crdPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/crdWebsite"
android:layout_alignParentLeft="true"
android:layout_marginBottom="17dp"
android:text="phone"
android:textColor="#20526d"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:id="#+id/crdName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/crdCompany"
android:text="name"
android:textColor="#20526d"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:id="#+id/crdTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/crdName"
android:layout_marginTop="12dp"
android:text="title"
android:textColor="#20526d"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:id="#+id/crdMobile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/crdTitle"
android:layout_marginTop="5dp"
android:text="mobile"
android:textColor="#20526d"
android:textSize="13sp"
android:textStyle="bold" />
<FrameLayout
android:id="#+id/frameLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="25dp" >
<ImageView
android:id="#+id/crdlogoframe"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentLeft="true"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="#drawable/border"
android:visibility="visible" />
</FrameLayout>
<ImageView
android:id="#+id/crdqrframe"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignTop="#+id/frameLayout1"
android:layout_toRightOf="#+id/frameLayout1"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="#drawable/border" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/bottomrltv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_marginTop="10dp"
android:gravity="bottom" >
<Button
android:id="#+id/btnsend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/view"
android:layout_weight="1"
android:text="Send" />
<View
android:id="#+id/view"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_centerHorizontal="true" />
<Button
android:id="#+id/btnedit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/btnsend"
android:layout_toRightOf="#+id/view"
android:layout_weight="1"
android:text="Edit" />
</RelativeLayout>
Note: .xml file demonstrates whole interface, not only RelativeLayout.
If i understand you correctly you need to center imageview with id blankcard inside his parent relativelayout? Then you can set android:centerInParent='true'...
In my app am using customized listed view with text view and Buttons.The screen size is 4.65" 720p(720X1280 : xhdpi),device take this resolution from layout-large folder.when i run it on device.the list view item and header display not fit to the screen like image shown below,some empty space in the end of row.Its not able to fit to the screen.Can any one know please help me to solve this issue.
Header XML Coding
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/search_lay"
android:layout_marginTop="1dp"
android:background="#e8e8e8" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="32dp"
android:text="Item(s)"
android:textColor="#dd1713"
android:textSize="13sp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="48dp"
android:layout_toRightOf="#+id/textView1"
android:text="Price(Rs.)"
android:textColor="#dd1713"
android:textSize="13sp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="18dp"
android:layout_toRightOf="#+id/textView3"
android:text="Qty"
android:textColor="#dd1713"
android:textSize="13sp" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="28dp"
android:layout_toRightOf="#+id/textView2"
android:text="Total(Rs.)"
android:textColor="#dd1713"
android:textSize="13sp" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="3dp"
android:text="Fav"
android:textColor="#dd1713"
android:textSize="13sp" />
</RelativeLayout>
Customized List-view XML Coding
<?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" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#ffffff" >
<TextView
android:id="#+id/orderlist_product_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:visibility="gone" />
<RelativeLayout
android:layout_width="30dp"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/fav_img"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="#drawable/fav_order_list_btn" />
<Button
android:id="#+id/special_inst_btn"
android:layout_width="25dp"
android:layout_height="18dp"
android:layout_below="#+id/fav_img"
android:layout_centerHorizontal="true"
android:background="#drawable/special_inst_btn_in_orderlist"
android:gravity="center"
android:text="+"
android:textColor="#ffffff"
android:textSize="14sp" />
</RelativeLayout>
<TextView
android:id="#+id/order_list_itemname"
android:layout_width="95dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="1dp"
android:text="Item name"
android:textColor="#000000"
android:textSize="12sp"
android:typeface="serif" />
<RelativeLayout
android:layout_width="34dp"
android:layout_height="match_parent"
android:layout_marginLeft="2dp" >
<TextView
android:id="#+id/orderlist_offer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="4dp"
android:gravity="center"
android:textColor="#298616"
android:textSize="10sp" />
<TextView
android:id="#+id/orderlist_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="right"
android:text="200.00"
android:textColor="#000000"
android:textSize="10sp"
android:typeface="serif" />
</RelativeLayout>
<Button
android:id="#+id/orderlist_minus"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginTop="1dp"
android:background="#drawable/sub_button_click" />
<EditText
android:id="#+id/order_list_quantity"
android:layout_width="27dp"
android:layout_height="25dp"
android:layout_marginTop="13dp"
android:background="#drawable/et_bg"
android:ems="10"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="center"
android:inputType="number"
android:textColor="#000000"
android:textSize="12dp"
android:typeface="serif" >
<requestFocus />
</EditText>
<Button
android:id="#+id/orderlist_plus"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:layout_marginTop="1dp"
android:background="#drawable/plus_btn_click" />
<TextView
android:id="#+id/orderlist_total"
android:layout_width="43dp"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginTop="13dp"
android:gravity="right"
android:text="1000.00"
android:textColor="#000000"
android:textSize="11sp"
android:typeface="serif" />
<Button
android:id="#+id/orderlist_delete"
android:layout_width="23dp"
android:layout_height="23dp"
android:layout_gravity="center"
android:layout_marginLeft="3dp"
android:layout_marginTop="1dp"
android:background="#drawable/order_list_delete" />
</LinearLayout>
</RelativeLayout>
i m giving u a demo.this layout will work on all size layout,this will definitely help u #Yugesh.
weight works percentage-wise on all screen.
<?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" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".30"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/image1"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".30"
android:text="30%" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".20"
android:text="20%" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".20"
android:text="20%" />
</LinearLayout>
</RelativeLayout>
further more,if there is any query,then please ask...
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dip" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip"
android:padding="1dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="20dp"
android:text="Total Pregnancies"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="30dp"
android:text="10"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="160dp"
android:text="Full Term"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="75dp"
android:text="11"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="190dp"
android:text="Premature"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="30dp"
android:text="12"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/linearLayout1"
android:layout_below="#+id/linearLayout1"
android:layout_marginTop="35dp"
android:padding="1dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="20dp"
android:text="Multiples"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="85dp"
android:text="16"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="160dp"
android:text="Living"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="95dp"
android:text="17"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/linearLayout1"
android:layout_centerVertical="true"
android:padding="1dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="20dp"
android:text="Ab Included"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="70dp"
android:text="13"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="160dp"
android:text="Ab Spontaneous"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="30dp"
android:text="14"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="190dp"
android:text="Ectopics"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="35dp"
android:text="15"
android:textColor="#000000" />
</LinearLayout>
</RelativeLayout>
This is how the screen looks, can anyone tell me how can i achieve this layout. i have come up with the layout, but it seems it does not fit for all screens.
Make the LinearLayout width fill_parent to use the entire width of the screen.
Then for each TextView, set the layout_width to 0dp, and set layout_weight to the proportion of the screen you want that view to have.
In the padding, specify the minimum amount you want between the different cells.
For example, if you want the text to occupy double the space of the numbers, use the following code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dip" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip"
android:padding="1dip" >
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="Total Pregnancies"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="10"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="Full Term"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="11"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="Premature"
android:textColor="#000000" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:text="12"
android:textColor="#000000" />
</LinearLayout>
</RelativeLayout>
Use TableLayout
Here is an example
I have a textview inside a scrollview. Under the scrollview there is a tablelayout with a lot of buttons. When i through code change the text of the scrollview, like this.
textViewInput.setText("Hello");
It makes the buttons in the tablelayout change gravity so that the text in them is left aligned. Why is this happening? And i´ve made sure that textviewinput is´nt null.
Here´s the xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/TableLayout1"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="10dp"
android:background="#DDD"
android:orientation="vertical" >
<ScrollView
android:background="#DDD"
android:id="#+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="#+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textViewInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:gravity="left"
android:textColor="#000"
android:text="_" />
<TextView
android:id="#+id/textViewResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="5dp"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
<TableLayout
android:id="#+id/TableLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<TableRow
android:id="#+id/TableRow07"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:gravity="center_vertical"
android:weightSum="5" >
<Button
android:id="#+id/Button06"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_root"
android:textColor="#android:color/primary_text_light"
android:gravity="center" />
<Button
android:id="#+id/bAsin"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:textColor="#android:color/primary_text_light"
android:gravity="center" />
<Button
android:id="#+id/bAcos"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:gravity="center"/>
<Button
android:id="#+id/batan"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.4"
android:gravity="center" />
</TableRow>
<TableRow
android:id="#+id/TableRow06"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:weightSum="5" >
<Button
android:id="#+id/Button04"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_pi"
android:textColor="#android:color/primary_text_light"
android:gravity="center" />
<Button
android:id="#+id/Button03"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="#string/_sin"
android:textColor="#android:color/primary_text_light"
android:gravity="center"/>
<Button
android:id="#+id/Button02"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_cos"
android:gravity="center" />
<Button
android:id="#+id/Button01"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.4"
android:text="#string/_tan"
android:gravity="center"/>
</TableRow>
<TableRow
android:id="#+id/TableRow05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:weightSum="5" >
<Button
android:id="#+id/bPow"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_pow"
android:textColor="#android:color/primary_text_light"
android:gravity="center"/>
<Button
android:id="#+id/blpar"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="#string/_lpar"
android:textColor="#android:color/primary_text_light"
android:gravity="center"/>
<Button
android:id="#+id/brpar"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_rpar"
android:gravity="center" />
<Button
android:id="#+id/bdiv"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.4"
android:text="#string/_div"
android:gravity="center" />
</TableRow>
<TableRow
android:id="#+id/TableRow04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:weightSum="5" >
<Button
android:id="#+id/b7"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_7"
android:textColor="#android:color/primary_text_light"
android:gravity="center"/>
<Button
android:id="#+id/b8"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="#string/_8"
android:textColor="#android:color/primary_text_light"
android:gravity="center"/>
<Button
android:id="#+id/b9"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_9"
android:gravity="center" />
<Button
android:id="#+id/bmul"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.4"
android:text="#string/_times"
android:textStyle="bold"
android:gravity="center" />
</TableRow>
<TableRow
android:id="#+id/TableRow03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:weightSum="5" >
<Button
android:id="#+id/b4"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_4"
android:textColor="#android:color/primary_text_light"
android:gravity="center" />
<Button
android:id="#+id/b5"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="#string/_5"
android:textColor="#android:color/primary_text_light"
android:gravity="center" />
<Button
android:id="#+id/b6"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_6"
android:gravity="center" />
<Button
android:id="#+id/bsub"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.4"
android:text="#string/_minus"
android:gravity="center"/>
</TableRow>
<TableRow
android:id="#+id/TableRow02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:weightSum="5" >
<Button
android:id="#+id/b1"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_1"
android:textColor="#android:color/primary_text_light"
android:gravity="center"/>
<Button
android:id="#+id/b2"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="#string/_2"
android:textColor="#android:color/primary_text_light"
android:gravity="center" />
<Button
android:id="#+id/b3"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_3"
android:gravity="center"/>
<Button
android:id="#+id/badd"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.4"
android:text="#string/_plus"
android:gravity="center"/>
</TableRow>
<TableRow
android:id="#+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:weightSum="5" >
<Button
android:id="#+id/b0"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:text="#string/_0"
android:textColor="#android:color/primary_text_light"
android:gravity="center"/>
<Button
android:id="#+id/bPoint"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:gravity="center"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="#string/dot"
android:textColor="#android:color/primary_text_light" />
<Button
android:id="#+id/bClear"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.2"
android:gravity="center"
android:text="#string/clear" />
<Button
android:id="#+id/bEnter"
style="#style/white_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1.4"
android:text="#string/enter" />
</TableRow>
</TableLayout>
</RelativeLayout>
Because of
<TextView
android:id="#+id/textViewInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
...
Using wrap_content means that your TextView's width and height will change depending of it's content, which you modify when you call setText().
Try using fixed width and height, like this:
<TextView
android:id="#+id/textViewInput"
android:layout_width="match_parent"
android:layout_height="30dp"
...