1

UI と、このユーザー インターフェイスのいくつかの要素があります。要素を常に垂直方向の中央に配置したい。問題は、設定layout_centerInParentすると中央揃えになりますが、下の要素をオーバーライドすることです。私はそれをしたくありません。現時点での外観は次のとおりです。

ここに画像の説明を入力

xml ファイルは次のとおりです。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"     >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginTop="@dimen/top_mr_image"
    android:src="@drawable/temp" />
<LinearLayout 
    android:id="@+id/r1"
    android:layout_width="match_parent"
    android:layout_height="80dp"
    android:layout_alignParentLeft="true"
    android:layout_centerInParent="true"
    android:background="@drawable/r1bg"
    android:layout_marginRight="35dp"
    android:layout_marginBottom="10dp"
    > 
    <TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:text="Start"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textSize="@dimen/txt_r4_size" />
 </LinearLayout>
 <LinearLayout 
    android:id="@+id/r2"
    android:layout_width="match_parent"
    android:layout_height="80dp"
    android:layout_alignParentLeft="true"
    android:layout_centerInParent="true"
    android:layout_below="@+id/r1"
    android:background="@drawable/r2bg"
    android:layout_marginRight="25dp"
    android:layout_marginBottom="10dp"
    > 
    <TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:text="HOW TO"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textSize="@dimen/txt_r4_size" />
    </LinearLayout>
   <LinearLayout 
    android:id="@+id/r3"
    android:layout_width="match_parent"
android:layout_height="80dp"
    android:layout_alignParentLeft="true"
    android:layout_centerInParent="true"
    android:layout_below="@+id/r2"
    android:background="@drawable/r3bg"
    android:layout_marginRight="15dp"
    android:layout_marginBottom="10dp"
    > 
    <TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:text="Support"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textSize="@dimen/txt_r4_size" />
 </LinearLayout>

<RelativeLayout
    android:layout_marginTop="20dp"
    android:id="@+id/r4"
    android:layout_width="fill_parent"
    android:layout_height="55dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:background="@drawable/r4bg"
    android:clickable="true"
    android:onClick="onClick" >

<TextView
    android:id="@+id/textView11"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:layout_marginLeft="10dp"
    android:text="You have:"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textSize="@dimen/txt_r4_size" />

    <TextView
        android:id="@+id/textView12"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@id/textView11"
        android:layout_marginLeft="20dp"
        android:text="0"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textSize="30dp" />
    <TextView
        android:id="@+id/textView13"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@id/textView12"
        android:layout_marginLeft="20dp"
        android:text="CCCCCC"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textSize="@dimen/txt_r4_size" />
</RelativeLayout>

常に垂直方向の中央に配置し、上部と下部の要素の一部をオーバーライドしないようにします。これを達成する方法は?さまざまな画面解像度用にハードコーディングしたくありません。

4

1 に答える 1

0

下部のアイテムが重ならないようにするには、垂直方向の中央に配置された最も高いビューを基準にしてそれらを作成する必要があります。重ならないように下揃えを設定します。

于 2013-01-29T15:45:26.173 に答える