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)。除非你把它放在一个滚动容器中,比如 a ScrollView,否则它永远不会超过屏幕的大小。

ImageView当您删除裁剪时,您没有显示“全宽和巨大”的原因是因为 an 的默认scaleTypeImageViewfitCenter。此特定视图受布局的宽度限制,因此它会在保持纵横比的同时缩小图像。

于 2013-10-03T16:58:29.537 回答