こんにちはドロイド!
何時間にもわたる調査の結果、説明のつかない厄介なレイアウトの問題に直面しています... :/。ここに提示する縮小テストケースを作成しました。
私は単純なリスト項目のレイアウトを持っています。
リスト項目 http://www.freeimagehosting.net/4075a.jpg
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="96dp">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:id="@+id/textView1" android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_centerVertical="true" android:layout_centerHorizontal="true" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="TextView"
android:id="@+id/textView2" android:layout_alignParentTop="true" />
<ImageView
android:layout_width="10dp"
android:layout_height="match_parent"
android:id="@+id/imageView1"
android:src="@drawable/errorindicator"
android:layout_below="@id/textView2" />
</RelativeLayout>
エラー インジケータは赤い四角形で、左側の画像で確認できます。xml は次のようになります。
<?xml version="1.0" encoding="utf-8"?>
<shape shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/ControllingConflictColor" />
<padding android:left="0dp" android:top="0dp"
android:right="0dp" android:bottom="0dp" />
</shape>
説明されているリスト項目のレイアウトは期待どおりに機能します。
上記のように、リストビューにリストアイテムを入力しようとしました。結果は次のようになります。
リスト アイテムを含むリスト ビュー http://www.freeimagehosting.net/4cc4b.jpg
対応するxml:
<?xml version="1.0" encoding="utf-8"?>
<ListView android:id="@+id/listView1" android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Preview: listitem=@layout/test -->
</ListView>
画像でわかるように、赤い四角形の高さが親と一致しなくなりました。画像はデザイナーが作成したものですが、エミュレーターやデバイスでも同様の効果が得られます。API レベル 8 向けに開発しています。
**説明されたレイアウトがリストビューで期待どおりに機能しない理由を誰かが説明してくれれば幸いです。シェイプ ドローアブルの動作が異なるのはなぜですか? **
お時間をいただきありがとうございます:)
編集: 画像の埋め込みに問題があります。代わりにリンクを使用しました。申し訳ありません;( 編集: xml-drawable タグを追加しました。
編集:私の例は、さらに簡単にすることができます。実際のレイアウトと似ているため、2 つのテキスト ビューを含めました。例から 2 つのテキスト ビューを削除できますが、レイアウトがリスト ビューで使用されている場合、イメージ ビューで描画可能な形状が、定義されている親の高さと一致しないという問題が依然として存在します。