2014-03-07 118 views
2

對準我在我的xml文件佈局的Android

<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> 

和輸出使用此代碼是尋找精細

enter image description here

,但是當我在寄存器按鈕點擊後自動改變對準

changed alignment

請幫助我如何,我可以解決這個問題

我所有的XML文件的代碼是

 <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> 

在此先感謝

任何幫助表示讚賞。

+0

檢查相同大小的焦點/選定/按鈕的按鈕尺寸在可繪製文件夾中選擇xml。因爲在選擇器xml中,我們將使用不同的按鈕尺寸和顏色來顯示按鈕的焦點/選擇。同時確認您沒有更改Java中的字體大小或文本。 – Shriram

回答

0

使用此。

<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> 
+0

感謝重播兄弟但是也出現了同樣的問題 – Kuldeep

1

剛剛從Buttons如下刪除android:layout_weight="0.5"屬性...

<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> 
+0

感謝重播兄弟,但沒有解決問題後刪除ndroid:layout_weight =「0.5」從按鈕 – Kuldeep

+0

你有沒有從兩個按鈕中刪除? –

+0

是從兩個按鈕中刪除了 – Kuldeep