以下は私の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>
True、実行時に項目が満たされると、ボタンは自動的に右側に移動します。 – Vivek