Android 沿RelativeLayout底部对齐未知高度图像
我需要有一个屏幕,屏幕底部有一个图像。映像本身是固定的(来自资源)。它相当大,可以缩小到每个设备的宽度。我尝试使用简单的Android 沿RelativeLayout底部对齐未知高度图像,android,image,layout,Android,Image,Layout,我需要有一个屏幕,屏幕底部有一个图像。映像本身是固定的(来自资源)。它相当大,可以缩小到每个设备的宽度。我尝试使用简单的布局\u alignParentBottom,如下所示: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/LayoutLoading"
布局\u alignParentBottom
,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LayoutLoading"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/startup" >
<ImageView
android:id="@+id/ImageView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:scaleType="fitCenter"
android:src="@drawable/loading" />
</RelativeLayout>
是的,这不起作用。除非我指定图像的确切高度(代替wrap\u content
),否则ImageView
不会在底部对齐。最有可能的原因是,实际图像比屏幕尺寸高,只有在缩小到屏幕宽度后才会变得“更短”
因此,问题是如何使
ImageView
保持在屏幕底部,而不考虑设备的大小?在xmlandroid:adjustViewBounds=“true”
中添加到您的ImageView中注:您可以删除android:orientation=“vertical”
因为这似乎是线性布局的遗留问题。
方法:@是的,你说得对,谢谢。