我正在尝试使用以下属性制作一个非常简单的布局:
这是它的外观示例:
我可以得到它由图像设置为水平和垂直比例放大和中心match_parent
的宽度和高度与指定scaleType
的fitCentre
。我也可以使用使其与右下角对齐fitEnd
。
我曾尝试将RelativeLayout
其居中放置在底部,但是如果将图像的宽度和高度设置为wrapContent
,这将导致它无法按比例放大,那么我只能使它起作用。
这是一个示例布局,可以用作起点:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="bottom|center_horizontal"
android:scaleType="fitStart"
android:src="@drawable/abc_ic_search" />
</RelativeLayout>
试试这个:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="@drawable/abc_ic_search"
android:adjustViewBounds="true"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句