3

ここで私が欲しいものを明確に説明してみましょう。ヘッダー画像とその下のコンテンツを含む RelativeLayout があります。

現在、ヘッダー画像とその下にリストビューがある場合、ページがデバイスの画面に適切に収まり、レイアウトが繰り返されません。

しかし、ヘッダー画像の下に画像を配置すると、デバイスでレイアウトが繰り返されます。つまり、デバイスに 2 つのヘッダー画像が表示されます。一部のページで、そこにあるはずのないヘッダー画像の半分が表示されました (ヘッダー画像の繰り返し)。ただし、エミュレーターでは、すべてのページが問題なく表示され、画面にうまく収まります。

LinearLayout、RelativeLayout 内部の LinearLayout、RelativeLayout に変更してみましたが、同じ結果になりました。なぜこれが起こったのか誰かが教えてくれることを願っています。ありがとう。

添付は私のレイアウトです。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/bg" >

<ImageView
android:id="@+id/header"
android:contentDescription="@string/image"
android:src= "@drawable/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="centerCrop"/>

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical" >

<ImageView
android:id="@+id/journal"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_alignTop="@+id/kick"
android:adjustViewBounds="true"
android:contentDescription="@string/image"
android:padding="10dp"
android:src="@drawable/favourite_journal" />

<ImageView
android:id="@+id/kick"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_toRightOf="@+id/journal"
android:layout_below="@+id/header"
android:adjustViewBounds="true"
android:contentDescription="@string/image"
android:padding="10dp"
android:src="@drawable/favourite_kick" />

<ImageView
android:id="@+id/labour"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_below="@+id/journal"
android:layout_alignLeft="@+id/journal"
android:adjustViewBounds="true"
android:contentDescription="@string/image"
android:padding="10dp"
android:src="@drawable/favourite_labour" />

<ImageView
android:id="@+id/share"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_below="@+id/kick"
android:layout_alignLeft="@+id/kick"
android:adjustViewBounds="true"
android:contentDescription="@string/image"
android:padding="10dp"
android:src="@drawable/favourite_share" />
</RelativeLayout>
</RelativeLayout>
4

1 に答える 1

3

私はそれを解決することができました。内部の RelativeLayout の layout_width と layout_height を fill_parent に設定する必要があります。

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/header"    
android:orientation="vertical">

@Ziteng Chen さん、ポジションについて教えてくれてありがとう。

android:layout_below="@+id/header"  

また、adjustViewBounds を削除するよう提案した @BobbiHoddi。画像で発生した他のエラーに役立ちました。

android:adjustViewBounds="true"
于 2012-10-16T05:57:58.360 に答える