具有重叠项的Android视图

具有重叠项的Android视图,android,android-layout,android-canvas,Android,Android Layout,Android Canvas,希望有一个看起来像下图的视图 将两个自定义视图放在一个相对布局中,将显示图像中显示的内容 是的,customview2在不绘制任何内容的区域是透明的。为了避免这种情况,您需要为该视图设置背景 你可以接受 例如-1: <FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.c

希望有一个看起来像下图的视图


将两个自定义视图放在一个相对布局中,将显示图像中显示的内容

是的,customview2在不绘制任何内容的区域是透明的。为了避免这种情况,您需要为该视图设置背景

你可以接受

例如-1:

 <FrameLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android">
    <ImageView 
        android:src="@drawable/icon"
        android:scaleType="fitCenter"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"/>
    <TextView
        android:text="Learn-Android.com"
        android:textSize="24sp"
        android:textColor="#000000"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:gravity="center"/>
</FrameLayout>

更新: 例如-2:极好的示例和技巧,可在此处找到:


建议您使用画布??如果不是,则使用RelativeLayout。它将帮助您创建这种类型的视图。
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 

        android:scaleType="center"
        android:src="@drawable/golden_gate" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dip"
        android:layout_gravity="center_horizontal|bottom"

        android:padding="12dip"

        android:background="#AA000000"
        android:textColor="#ffffffff"

        android:text="Golden Gate" />

</FrameLayout>