【发布时间】:2016-04-25 01:28:27
【问题描述】:
所以,我在 FrameLayout 中有一个 ImageView。我需要这种方式。我觉得这里的问题是图像及其大小本身。图像的布局将我屏幕上的所有其他视图进一步向下推,留下相当大的空白空间,这些空间应该来自布局。
我发现硬编码高度值可以让我尽量减少这个问题。如果高度为 wrap_content,则图像将到达同一点,但应该来自布局的空白区域会延伸到极端长度。
所以我想知道这是否是图像大小(或分辨率?)问题(似乎是)或其他任何问题,以及是否有比硬编码布局高度更好的解决方案。提前致谢。
代码如下:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="700dp">
<ImageView
android:id="@+id/image_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitStart"
android:src="@drawable/me_and_gundam" />
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/gradient" />
</FrameLayout>
<TextView
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="My Nanodegree Apps!"
android:textAlignment="center"
android:textSize="24sp" />
这是它的样子:
【问题讨论】:
标签: android android-layout android-imageview textview android-framelayout