Reputation: 367
i am using this code in my xml file
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="fill_vertical"
>
<Button
android:id="@+id/btn_signINlst"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="@drawable/draw"
android:text="@string/sign_in" />
<TextView
android:id="@+id/Left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:layout_gravity="center_vertical"
android:textColor="#000000"
android:text="@string/do_not_have_ac"
/>
<Button
android:id="@+id/btn_registerlst"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="@drawable/draw"
android:text="@string/register" />
</LinearLayout>
and output is looking fine
but when i click on register button then automatically changed alignment
Please help me how i can fix this problem
my all xml file code is
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/main_bg"
>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="40dip" android:layout_alignParentTop="true"
android:background="@drawable/tab_bar" android:id="@+id/rel_jobDesc">
<TextView android:layout_width="wrap_content"
android:id="@+id/txt_SEARCH_TITLE"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/search_results"
android:textStyle="bold"
android:textSize="20dip"
android:textColor="#fff"></TextView>
</RelativeLayout>
<ListView
android:id="@+id/mainlist"
android:cacheColorHint="#00000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/adView"
android:layout_below="@+id/rel_jobDesc"
android:smoothScrollbar="true"
android:scrollingCache="false"
android:dividerHeight="1dp"
android:divider="#adb8c2"
>
</ListView>
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adUnitId="ca-app-pub-2584288851778590/4570818460"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"
android:layout_above="@+id/AboveLinear"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"/>
<TextView
android:id="@+id/AboveLinear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/linearLayout1"
android:gravity="center_horizontal"
android:layout_centerHorizontal="true"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="13sp"
android:text="@string/take_advantage" />
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="fill_vertical"
>
<Button
android:id="@+id/btn_signINlst"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="@drawable/draw"
android:text="@string/sign_in" />
<TextView
android:id="@+id/Left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:layout_gravity="center_vertical"
android:textColor="#000000"
android:text="@string/do_not_have_ac"
/>
<Button
android:id="@+id/btn_registerlst"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="@drawable/draw"
android:text="@string/register" />
</LinearLayout>
</RelativeLayout>
Thanks In Advance
Any Help Is Appreciated.
Upvotes: 2
Views: 117
Reputation: 18933
Use this.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ic_launcher" >
<RelativeLayout
android:id="@+id/rel_jobDesc"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_alignParentTop="true"
android:background="@drawable/ic_launcher" >
<TextView
android:id="@+id/txt_SEARCH_TITLE"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="search_results"
android:textColor="#fff"
android:textSize="20dip"
android:textStyle="bold" >
</TextView>
</RelativeLayout>
<ListView
android:id="@+id/mainlist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/adView"
android:layout_below="@+id/rel_jobDesc"
android:cacheColorHint="#00000000"
android:divider="#adb8c2"
android:dividerHeight="1dp"
android:scrollingCache="false"
android:smoothScrollbar="true" >
</ListView>
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/AboveLinear"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-2584288851778590/4570818460"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" />
<TextView
android:id="@+id/AboveLinear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/linearLayout1"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:text="take_advantage"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="fill_vertical" >
<Button
android:id="@+id/btn_signINlst"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="@drawable/ic_launcher"
android:text="sign_in" />
<TextView
android:id="@+id/Left"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:gravity="center"
android:text="do_not_have_ac"
android:textColor="#000000" />
<Button
android:id="@+id/btn_registerlst"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="@drawable/ic_launcher"
android:text="register" />
</LinearLayout>
</RelativeLayout>
Upvotes: 0
Reputation: 9700
Just remove android:layout_weight="0.5"
attribute from Buttons
as below...
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="fill_vertical" >
<Button
android:id="@+id/btn_signINlst"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/draw"
android:text="@string/sign_in" />
<TextView
android:id="@+id/Left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:layout_gravity="center_vertical"
android:textColor="#000000"
android:text="@string/do_not_have_ac" />
<Button
android:id="@+id/btn_registerlst"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/draw"
android:text="@string/register" />
</LinearLayout>
Upvotes: 1