0

在此处输入图像描述我有一个RelativeLayout,里面有一些TextViews & ImageViews。我有一个图像设置为相对布局的背景,其高度大于子视图的总高度。因此,它在底部的子视图中留下了一些空白空间。那么,我怎样才能避免这个空白呢?我的意思是,是否可以在不考虑布局背景图像高度的情况下使布局高度完全等于子视图的总高度?

前任:

<RelativeLayout android:layout_width="wrap_content" 
        android:layout_height="wrap_content" android:background="@drawable/bg_image">
    <TextView />
    <ImageView /> 
</RelativeLayout/>

这里,'bg_image' 的高度大于 TextView 和 ImageView 的总高度。因此,它在 TextView 和 ImageView 之后留下了一些空白空间

4

3 回答 3

0

您可以尝试使用选项.. 我不知道您的XML 布局fill_parent中有多少控件.. 但可能会对您有所帮助..fill_parent

于 2013-04-02T07:21:41.123 回答
0

试试下面的代码

<RelativeLayout android:layout_width="fill_parent" 
        android:layout_height="fill_parent" android:background="@drawable/bg_image">
    <TextView />
    <ImageView /> 
</RelativeLayout/>
于 2013-04-02T07:21:48.767 回答
0

我相信问题在于RelativeLayout它从背景图像计算它的高度。尝试设置一个9-patch图像。然后它将根据需要拉伸以填充布局,它应该有android:layout_height="wrap_content"

于 2013-04-02T08:55:37.893 回答