0

相対レイアウトで画像のサイズを大きくしようとしています。現在、その幅と高さは に設定されていwrap_contentます。それらを設定するfill_parentと、画像は大きくなりますが、ディスプレイの下にあるボタンを押してしまいます。関連する XML を以下に示します。私は何を間違っていますか?

編集:すべての回答に感謝しますが、これまでのところ、画像の高さをfill_parentまたはに設定するmatch_parentと、ボタンが相対レイアウトの内外にあるかどうかに関係なく、常にディスプレイの下部まで拡張されます。相対レイアウトがその下にあるものを無視するのはなぜですか?

<LinearLayout>
    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/relativelayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/myImageView"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:src="@drawable/apple"
            android:alpha=".5"
            android:paddingBottom="0dp"
            android:adjustViewBounds="true" />
        <TextView
            android:id="@+id/myImageViewText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="Sample"
            android:textColor="#000000"
            android:singleLine="true"
            android:layout_alignLeft="@+id/myImageView"
            android:layout_alignStart="@+id/myImageView"
            android:layout_alignParentTop="true" />


    </RelativeLayout>

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/enterPluButton"
        android:background="#FFBD5C"
        android:textColor="#000000"
        android:text="Submit" />
</LinearLayout>
4

4 に答える 4

1
  1. android:layout_alignParentBottom="true"ボタンに設定します。
  2. android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/enterPluButton"RelativeLayout の設定
  3. android:layout_width="match_parent" android:layout_height="match_parent"ImageView の設定
于 2015-05-16T04:15:27.947 に答える
0

RelativeLayoutView互いの相対的な位置。別の子との関係がない場合はView、親Viewであるで計算されRelativeLayoutます。これがあなたがそれを持っている理由です。LinearLayoutをラップしScrollViewたりRelativeLayout、固定サイズを指定したりしないのはなぜですか

于 2015-05-16T03:43:47.830 に答える