7

特定の制限を超えて伸びない垂直線形レイアウトがあります。

これは、イメージビューで centerCrop を使用したレイアウトです http://tinypic.com/r/20nm6s/5

これはクロップ セットのないレイアウトです (全幅で巨大なはずです) http://tinypic.com/r/vzk7kw/5

私の考えでは、レイアウトに表示されていない暗黙の最大高さがあると思いますが、それがどこにあるのかわかりません。エラーを見つけることができますか?

<?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="wrap_content"
            >
    <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:background="@drawable/dropshadow"
            >
        <TextView
                android:id="@+id/heading"
                android:layout_gravity="center"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                />
        <ImageView
            android:id="@+id/featuredimage"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:maxHeight="1000dp"
            android:scaleType="centerCrop"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp"
            />
    </LinearLayout>
</RelativeLayout>
4

1 に答える 1

2

レイアウトの「暗黙の」最大高さは、その親の高さです。両方のレイアウトで使用wrap_contentしているため、親は実質的に画面領域であり、使用している他のビュー ( などTextView) を除いたものです。などのスクロール コンテナーに配置しない限りScrollView、画面のサイズを超えることはありません。

ImageViewクロップを削除したときに「全幅で巨大」に表示されない理由は、のデフォルトscaleTypeが. この特定のビューはレイアウトのによって制限されるため、アスペクト比を維持しながら画像を縮小します。ImageViewfitCenter

于 2013-10-03T16:58:29.537 に答える