Android 重叠的两个圆形图像视图

Android 重叠的两个圆形图像视图,android,android-imageview,Android,Android Imageview,我正在进行以下设计: 我使用以下代码在android中实现了这一点: 1.活动\u welcome.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="mat

我正在进行以下设计:

我使用以下代码在android中实现了这一点:

1.活动\u welcome.xml

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg"
    android:orientation="vertical">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="@dimen/margin40"
        android:text="Welcome to Almachat"
        android:textColor="#ffffff"
        android:textSize="20dp" />

    <com.almabay.almachat.circularImageView.CircularImageView
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_marginLeft="210dp"
        android:background="@drawable/color" />
    <com.almabay.almachat.circularImageView.CircularImageView
        android:id="@+id/profilePic"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_gravity="center"
        android:layout_marginTop="-50dp" />

    <TextView
        android:id="@+id/txtName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:textColor="#ffffff"
        android:textSize="30dp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/txtSomeText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Some static text will be here"
        android:textColor="#ffffff"
        android:textSize="20dp" />

    <Button
        android:id="@+id/btnContinue"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="@dimen/margin20"
        android:background="#F7AE21"
        android:padding="@dimen/padding20"
        android:text="Continue"
        android:textColor="#ffffff" />
</LinearLayout>
    <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <gradient
        android:angle="270"
        android:endColor="#F7AE21"
        android:startColor="#F7AE21" />
    <stroke
        android:width="10dp"
        android:color="#F7AE21"></stroke>
</shape>
使用上述代码后,我得到以下设计:


我的问题是,具有橙色的圆形图像视图应该位于具有纵断面图的圆形图像视图的上方。但是这里的纵断面图位于具有橙色的图像视图的上方。我如何修复它?

我认为这很容易

只需切换xml中的CircularimageView

所以


变成

<com.almabay.almachat.circularImageView.CircularImageView
    android:id="@+id/profilePic"
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_gravity="center"
    android:layout_marginTop="-50dp" />
<com.almabay.almachat.circularImageView.CircularImageView
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:layout_marginLeft="210dp"
    android:background="@drawable/color" />

xml中的视图是按顺序添加的,因此最新添加的视图将位于顶部

我想在那之后你应该调整一下marginTops

编辑: 我认为更好的解决方案是将两个CircularimageView包装在一个FrameLayout中。
你能试试这样的东西,或者根据你的喜好调整一下尺寸吗

<FrameLayout
    android:layout_width="220dp"
    android:layout_height="230dp"
    android:layout_gravity="center">
    <com.almabay.almachat.circularImageView.CircularImageView
        android:id="@+id/profilePic"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_gravity="bottom" />
    <com.almabay.almachat.circularImageView.CircularImageView
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_gravity="top|right"
        android:background="@drawable/color" />
</FrameLayout>


你应该在布局中把橙色的放在蓝色的之后。

使用RelativeLayout进行图像处理,而RelativeLayout末尾的视图显示在顶部,其他视图被它重叠。

你可以使用FrameLayout进行此操作..谢谢Ivo。这对我来说很有效。但是处理这个问题变得很困难现在布局。因为我需要设置一些负值的边距来显示视图。
<com.almabay.almachat.circularImageView.CircularImageView
    android:id="@+id/profilePic"
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_gravity="center"
    android:layout_marginTop="-50dp" />
<com.almabay.almachat.circularImageView.CircularImageView
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:layout_marginLeft="210dp"
    android:background="@drawable/color" />
<FrameLayout
    android:layout_width="220dp"
    android:layout_height="230dp"
    android:layout_gravity="center">
    <com.almabay.almachat.circularImageView.CircularImageView
        android:id="@+id/profilePic"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_gravity="bottom" />
    <com.almabay.almachat.circularImageView.CircularImageView
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_gravity="top|right"
        android:background="@drawable/color" />
</FrameLayout>