2011-09-19 92 views
2

我知道有這樣的問題,但大部分時間似乎他們的問題是他們沒有將佈局對齊爲填充父項。好吧,我這樣做,我不知道爲什麼我的按鈕仍然不會這樣做。難道是因爲我使用的所有佈局?其他右側的一個按鈕

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/face"> 

    <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="100dp" android:gravity="center"> 
    <ImageView android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:id="@+id/eyes" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/eyes1" /> 
     <LinearLayout android:layout_marginTop="50dp" android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="horizontal"> 
      <Button android:id="@+id/eyesback" android:layout_width="50dp" android:layout_height="50dp" /> 
      <Button android:id="@+id/eyesforward" android:layout_height="50dp" android:layout_width="50dp" android:layout_gravity="right"></Button> 
     </LinearLayout> 
    </RelativeLayout> 

</LinearLayout> 

它可能是一些簡單的我也錯過了。謝謝你的幫助。

回答

1

試試這個

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/face"> 

    <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="100dp" android:gravity="center"> 
    <ImageView android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:id="@+id/eyes" android:background="@drawable/eyes1" android:layout_width="fill_parent" android:layout_height="wrap_content"/> 
     <RelativeLayout android:layout_marginTop="50dp" android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="horizontal"> 
      <Button android:id="@+id/eyesback" android:layout_width="50dp" android:layout_height="50dp" android:layout_alignParentLeft="true"/> 
      <Button android:id="@+id/eyesforward" android:layout_height="50dp" android:layout_width="50dp" android:layout_gravity="right" android:layout_alignParentRight="true"></Button> 
     </RelativeLayout> 
    </RelativeLayout> 

</LinearLayout> 

我都德的LinearLayout成相對佈局和設置屬性簡單地改變一個按鈕即可下車離開了一個又一個的權利。

1
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/face"> 

    <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="100dp" android:gravity="center"> 
    <ImageView android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:id="@+id/eyes" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/eyes1" /> 
      <Button android:id="@+id/eyesback" android:layout_width="50dp" android:layout_height="50dp" android:layout_alignParentLeft="true"/> 
      <Button android:id="@+id/eyesforward" android:layout_height="50dp" android:layout_width="50dp" android:layout_gravity="right" android:layout_alignParentRight="true"></Button> 
    </RelativeLayout> 

</LinearLayout> 

嘗試一下

+0

謝謝,但它仍然沒有移動它們。 – steven

+0

你想要一個按鈕在父母的左邊,一個在右邊,那麼它工作正常 –