Android布局高度问题

时间:2013-04-02 07:06:47

标签: android android-layout

enter image description here我有一个RelativeLayout,我有一些TextViews&里面的ImageViews。我有一个图像集作为RelativeLayout的背景,其高度大于子视图的总高度。因此,它会在底部的儿童视图中留下一些空白区域。那么,我该如何避免这个空白呢?我的意思是,是否可以在不考虑布局背景图像高度的情况下使布局高度完全等于子视图的总高度?

例如:

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

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

3 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

尝试以下代码

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

答案 2 :(得分:0)

我认为问题在于RelativeLayout从它的背景图像计算它的高度。请尝试设置9-patch图片。然后它将尽可能多地拉伸以填充布局,该布局应该具有android:layout_height="wrap_content"