0

私は次のXMLレイアウトを持っています

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/mainLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|center_vertical">

            <ImageView
                android:id="@+id/IVLEFT"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_alignParentLeft="true"
                android:background="#ff0000"
                android:padding="1dp"
                />

            <ImageView
                android:id="@+id/IVRIGHT"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_toRightOf="@+id/IVLEFT"
                android:layout_alignParentRight="true"
                android:layout_alignBottom="@+id/IVLEFT"
                android:layout_alignTop="@+id/IVLEFT"
                android:src="@drawable/shadow_pages"
                android:background="#00ff00"
                android:padding="1dp" />
    </RelativeLayout>

レイアウトには2つのImageViewがあります。1つは左に、もう1つは右にあります。しかし、実際に起こることは次のとおりです。

実行時に、IVLEFTの画像を大きな画像(たとえば1024X768)に設定しました-そしてそれは私のレイアウトのすべてをカバーし、IVRIGHTを放棄します(私はそれを見ることができません)

何か案は?

4

4 に答える 4

0

これを試して::

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/mainLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|center_vertical">

            <ImageView
                android:id="@+id/IVLEFT"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:background="#ff0000"
                android:padding="1dp"
                android:src="@drawable/ic_launcher"/>

            <ImageView
                android:id="@+id/IVRIGHT"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/IVLEFT"
                android:layout_alignParentRight="true"
                android:layout_alignBottom="@+id/IVLEFT"
                android:layout_alignTop="@+id/IVLEFT"
                android:src="@drawable/ic_launcher"
                android:background="#00ff00"
                android:padding="1dp" />
    </RelativeLayout>
于 2012-10-16T09:39:10.083 に答える
0

これは、最初のImageView幅と高さを に指定したためですfill_parent。したがって、レイアウト全体を取得します。Imageviewまた、最初の画像に大きな画像を指定すると、レイアウト全体が使用されるため、レイアウトは最初の画像に依存します。

2 つの画像を並べて表示する場合は、linearlayoutwith layout_weightsto twoを使用してみてくださいimageViews

また、RelativeLayout幅と高さを fill_parent

于 2012-10-16T08:18:06.357 に答える
0

それはあなたRelativeLayoutwrap_content幅が広いからです。画面の外にある場合でも、必要なすべてのスペースが必要です。

fill_parent代わりに使用してください。

于 2012-10-16T08:21:42.657 に答える
0
  1. RelativeLayout の幅をfill_parent

  2. id = "@+id/magazineImageView"xml にImageView がありません"@+id/IVLEFT"。つまり、最初の画像自体が画面の幅全体を占めているため、2 番目の画像は表示されません。

  3. 2 番目の画像を表示する場合は、ImageView の幅wrap_contentまたはハードコードされた値の両方を作成します。

  4. さらに重要なことは、ビュー ID を参照として使用している場合は、ID に+記号を使用しないことです。+記号は、初めてビューの ID を定義するために使用されます

使用する:

android:layout_toRightOf="@id/magazineImageView"
于 2012-10-16T08:40:12.543 に答える