2011-02-03 8 views
1

以下は私のXMLです button1を左中央に、button2を右中央に垂直に設定したいのですが、私にとってはandroid:layout_gravity="center_vertical|right"は何が問題なのですか? 私はパディングやマージンを使って適用することでこれを達成できると知っていますが、なぜそれが機能していないのか分かりません。 どうすればいいですか?あなたは結果としてFrameLayoutが削除.IF fill_parentにその幅を作ることができないされ、HorizontalScrollViewを使用しているようここAndroid layout_gravityに問題がありますか?

<?xml version="1.0" encoding="utf-8"?> 
<HorizontalScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <FrameLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Button1" 
       android:layout_gravity="center_vertical" 
       /> 
     <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Button2" 
       android:layout_gravity="center_vertical|right"/> 
     <RelativeLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 
     </RelativeLayout> 
    </FrameLayout> 
    </HorizontalScrollView> 

答えて

1

あなたの問題があるHorizontalScrollViewあなたは私が考える望ましい結果を得るでしょう。

+0

True、実行時に項目が満たされると、ボタンは自動的に右側に移動します。 – Vivek

0

あなたがのLinearLayoutHorizo​​ntalScrollViewを交換する場合は、[はい、あなたは所望の効果が表示されます。

関連する問題