2016-09-10 7 views
0

ヘッダー、中央イメージ、およびフッターを含むリストビューでセルをレイアウトしようとしています。 セルは固定された高さになり、ビューからフッターを押さなくてもイメージを可能な最大幅まで比例的に拡大することができます。 これはXMLレイアウトで可能ですか?他のアイテムを表示せずにレイアウト内のサイズイメージを最大幅に調整する

私は、このレイアウトを持つ単純な例を設定している:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:orientation="vertical" 
       android:layout_width="match_parent" 
       android:layout_height="100dp" 
    > 
    <TextView 
     android:id="@+id/heading" 
     android:textColor="#000000" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 
    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:src="@drawable/placeholder" 
     /> 
    <TextView 
     android:textColor="#000000" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="footer"/> 
</LinearLayout> 

高さは、上記のように制約されている場合、フッターが表示されていない:

No Footer

は、私は理解している「match_parent」私はImageViewの幅に欲しいものではないかもしれませんが、画像のサイズを設定して使用可能なスペースしか使用しないようにするにはどうしたらいいですか?ここ@I_A_Mokへ

+0

あなたが期待しているいくつかのレイアウト上のスクリーンショットを共有することができますか? – Nikhil

+0

@indramurari上のスクリーンショットから欠落しているのは、「フッター」テキストだけです。それは見解から追い出されている。私が望むのは、画像をフッタに収まるだけで収縮させることです。 私が試したすべてのレイアウトは、上記のスクリーンショットのようにフッターをプッシュしたか、イメージが小さくなるようにイメージを縮小しました。 – zorro2b

+0

相対レイアウトで試してみてください。両方のTextViewを最初に、ヘッダーを親の上に、フッターを親の下に整列させます。次に、ImageView、match_parent、下のヘッダと上のフッターを作成します。それは助けて欲しい! –

答えて

0

おかげで改訂されたレイアウトです:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:layout_height="150dp" 
> 
<TextView 
    android:id="@+id/heading" 
    android:textColor="#000000" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true"/> 
<TextView 
    android:id="@+id/footer" 
    android:textColor="#000000" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="footer" 
    android:layout_alignParentBottom="true"/> 
<ImageView 
    android:layout_weight=".8" 
    android:adjustViewBounds="true" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:src="@drawable/placeholder" 
    android:layout_below="@+id/heading" 
    android:layout_above="@+id/footer" 
    /> 

</RelativeLayout> 
関連する問題