我正在尝试放置一个填充屏幕宽度的图像,具有实际图像的高度(wrap_content)并位于布局的最底部。
我编写了下面的代码,但是在第二个ImageView(带有drawable / user_board的那个)和屏幕的最底部之间,有一个小空间。为什么是这样?我已经尝试将填充和边距设置为0dp,但似乎它没有做到这一点。有什么想法吗?
以下是代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/LayoutBoard"
android:noHistory="true"
android:padding="0dp" >
<ImageView
android:src="@drawable/game_interface_background"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="matrix" />
<ImageView
android:src="@drawable/user_board"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="0dp"
android:padding="0dp" />
</RelativeLayout>
答案 0 :(得分:2)
您的user_board
图片底部是否有透明空间?或者,您可以尝试在第二个ImageView
的填充字段中设置负值。
答案 1 :(得分:1)
使用android:scaleType="fitXY"
,ImageView
中包含的位图将调整大小以适应整个ImageView
。因此,在两个imageView中使用此属性可能会隐藏该空白区域。但请记住,这不会保持图像的纵横比。有关android:scaleType
属性标记及其可能采用的值的详细信息,请参阅here。