【发布时间】:2012-07-12 14:27:12
【问题描述】:
我正在尝试放置一个填充屏幕宽度的图像,具有实际图像的高度 (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>
【问题讨论】:
-
您是否使用hierarchyviewer 来查看实际的填充和边距值在运行时的样子?
-
嗯。不,我以前没用过,但我会用谷歌搜索它。谢谢。
-
对这类事情非常有用。祝你好运!