1

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

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

2 に答える 2

1

ここであなたの問題は を使用しているためです。そのHorizontalScrollView結果FrameLayout、幅を にすることができませんfill_parent。を削除するHorizontalScrollViewと、目的の結果が得られると思います。

于 2011-02-03T05:52:26.513 に答える
0

はい、 Horizo​​ntalScrollView を LinearLayout に置き換える目的の効果が得られます。

于 2011-10-24T21:41:46.157 に答える