视图的背景放在元素上

时间:2013-03-08 13:04:25

标签: android view background relativelayout

下午好!我希望在我的视图中使用图像作为背景,问题是当我使用图像时(使用颜色完美地工作)背景被放置在元素上,因此不可能看不到任何内容。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Greet"
    android:background="@drawable/fondo_panel" >

    <ImageView android:layout_height="wrap_content" 
    android:layout_width="match_parent" 
    android:src="@drawable/logo_panel"/>

</RelativeLayout>

你知道这是什么问题吗?非常感谢!

1 个答案:

答案 0 :(得分:1)

为什么不将图像作为背景添加到RelativeLayout?因此,您不需要ImageView,也不需要重叠。

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Greet"
    android:background="@drawable/logo_panel" >

</RelativeLayout>