0

これは、Eclipse がエディターに表示するものです。

http://i.stack.imgur.com/tjwu9.png

スマホで実行するとこんな感じ。

http://i.stack.imgur.com/V6NG5.png

これは私が使用しているコードです。

   <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="bottom" >

    <Button
        android:id="@+id/buttonLocation"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/settings_button"

        android:text="Settings" android:textStyle="bold" android:textSize="24dp"  android:textColor="#000000" android:gravity="center_horizontal"/>
</LinearLayout>

中央に配置する必要があります。この問題を解決するにはどうすればよいですか?

4

2 に答える 2

0

これを試して

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="bottom" >

    <Button
        android:id="@+id/buttonLocation"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/settings_button"
        android:gravity="center"
        android:text="Settings" android:textStyle="bold" android:textSize="24dp"  android:textColor="#000000" android:gravity="center_horizontal"/>
</LinearLayout>
于 2012-05-26T19:52:59.113 に答える
0

android:layout_gravity は、親に対するビューまたはレイアウトの重力を設定するために使用されます。

ボタン要素については、 android:layout_gravity="center" これを中央に配置する必要があります。

また、確かではありませんが、選択したテキストサイズが原因で異なる結果が得られる可能性があります...小さい/大きいサイズを試して、結果が異なるかどうかを確認してください.

于 2012-05-26T20:03:17.047 に答える