2010-01-21 49 views
0
<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="50dip"> 
    <Button 
     android:text="Edit" 
     android:width="50dip" 
     android:layout_height="fill_parent" 
     android:layout_width="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" /> 
    <ToggleButton 
     android:textOn="All" 
     android:textOff="Wishlist" 
     android:layout_height="fill_parent" 
     android:layout_width="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentTop="true" /> 
    <Button 
     android:text="+" 
     android:width="50dip" 
     android:layout_height="fill_parent" 
     android:layout_width="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" /> 
</RelativeLayout> 

enter image description hereAndroid佈局如何?

我有這三個按鈕我要對齊它們以類似的方式對iPhone版本。我嘗試過使用重力和東西,但我似乎無法讓它們看起來沒有絕對定位一樣。

謝謝

所以我想通了。如果有人需要它,我用解決方案替換原始代碼。

回答

0

我能得到非常接近用這個佈局:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="50dip"> 

    <Button 
     android:text="Edit" 
     android:width="50dip" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_alignParentLeft="true"/> 

    <ToggleButton 
     android:text="Toggle" 
     android:textOn="All" 
     android:textOff="Wishlist" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_centerHorizontal="true"/> 

    <Button 
     android:text="+" 
     android:width="50dip" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_alignParentRight="true"/> 
</RelativeLayout> 
+0

您的回答與我的解決方案類似。感謝您推薦正確的解決方案。 – Jared 2010-01-21 21:02:05

0

我會親自使用TableLayout來實現這一點。

+0

感謝您的建議。我認爲有一種方法可以實現這一點,而不需要擴展視圖層次結構,而需要更多的視圖組。 – Jared 2010-01-21 21:01:00