-1

次のコードを見てください

<ScrollView 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"
    tools:context=".DisplayResult" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_gravity="center"
        android:gravity="center"
        >

        <ImageView
            android:id="@+id/zodiac1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/aries"
            />

        <TextView
            android:id="@+id/orTxt"
            android:text="Or"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            />

        <ImageView 
            android:id="@+id/zodiac2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/gemini"
            />

    </LinearLayout>




    </ScrollView>

この「LinearLayout」を上部中央に配置したい。デバイス画面の正確な中央ではありません。どうすればいいですか?助けてください!

編集

つまり、線形レイアウト内のものをアプリケーションの上部に表示したいということです。それらはそのスペースの中央に配置する必要があります。RelativeLayoutを使用する場合、これが私が行うことです

android:layout_centerHorizontal="true"
android:layout_alignTop="true"
4

1 に答える 1

2

RelativeLayout を複製したい場合は、次alignTopを試してください。

<ScrollView 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"
    tools:context=".DisplayResult" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center_horizontal" >
于 2012-12-27T20:35:26.627 に答える