-1

この画像http://postimg.org/image/h8akuq9gz/は、私が何を望んでいるかのアイデアを提供するはずです。デバイスが垂直または水平の位置にあるかどうかに関係なく、この 2 つの「円」は常に中央にある必要があります。

どうすればこれを達成できるか本当にわかりません。方向を教えてもらえますか?ありがとう!

4

4 に答える 4

2

次のように、ルート レイアウトで重力を使用しない理由は次のとおりです。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="vertical"
          android:gravity="center_vertical"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent">

 <Button
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"/>

 <Button
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"/>

</LinearLayout>
于 2013-10-15T11:35:01.147 に答える
0

これを試すことができますか: 例は画像ボタン用ですが、必要に応じて試すことができます

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout android:id="@+id/RelativeLayout01" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        xmlns:android="http://schemas.android.com/apk/res/android">

        <ImageButton android:id="@+id/btnFindMe" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:background="@drawable/findme"></ImageButton>

    </RelativeLayout>
于 2013-10-15T11:43:30.173 に答える
0

使用する

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
     gravity="center">

             <--Other contorls you want to keep in center-->

</RelativeLayout>
于 2013-10-15T11:33:45.830 に答える