【发布时间】:2015-05-16 19:34:56
【问题描述】:
我正在尝试在相对布局中增加图像的大小。现在,它的宽度和高度设置为wrap_content。当我将它们设置为fill_parent 时,图像会变大,但会将下方的按钮推离显示屏。相关的 XML 如下。我究竟做错了什么?
编辑:感谢所有答案,但到目前为止,如果我将图像的高度设置为fill_parent 或match_parent,它总是延伸到显示屏的底部,无论按钮是在还是在相对布局之外。为什么相对布局会忽略它下面的内容?
<LinearLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativelayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/myImageView"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/apple"
android:alpha=".5"
android:paddingBottom="0dp"
android:adjustViewBounds="true" />
<TextView
android:id="@+id/myImageViewText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Sample"
android:textColor="#000000"
android:singleLine="true"
android:layout_alignLeft="@+id/myImageView"
android:layout_alignStart="@+id/myImageView"
android:layout_alignParentTop="true" />
</RelativeLayout>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/enterPluButton"
android:background="#FFBD5C"
android:textColor="#000000"
android:text="Submit" />
</LinearLayout>
【问题讨论】:
-
我更新了我的答案。如果您希望它不被 ImageView 向下推,则必须在 Button 上使用 layout_alignBottom 而不是 layout_below。
标签: android image layout fill-parent