【发布时间】:2013-04-17 07:32:38
【问题描述】:
我正面临RelativeLayout 屏幕外按钮显示的问题。 ImageView 不会缩放图片以使按钮可见。
我有什么:
我想要什么:
代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical" >
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/str"
android:textAppearance="@android:style/TextAppearance.Small"
android:textColor="?android:attr/textColorTertiary"
android:layout_centerHorizontal="true"
/>
<ru.mw.widget.DrawableImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView"
android:adjustViewBounds="true"
android:layout_centerHorizontal="true"
android:scaleType="centerCrop"
/>
<Button
android:id="@+id/processButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/str"
android:layout_below="@+id/imageView"
android:layout_centerHorizontal="true"
/>
更改屏幕方向时的问题: 如果我在横向模式下使用 Arun C Thomas's method 一切正常,但在纵向模式下我有这个(图像被左/右边缘裁剪):
预期:
【问题讨论】:
-
将 android:alignParentBottom 添加到您的按钮,并将 android:alignParentTop (both = true) 添加到您的 Textview。您目前没有为 ImageView 设置任何边界。
标签: android xml android-layout android-relativelayout