Android Studio如何正确地将两个视图相互叠加?

时间:2019-03-14 19:08:29

标签: java android

我有一个框架布局,其中有一个自定义视图和一个ImageView。它们应该彼此精确地叠在一起。

我当前的xml代码:

<FrameLayout
    android:id="@+id/flayout"
    android:layout_width="0dp"
    android:layout_height="400dp"
    android:layout_marginTop="50dp"
    android:layout_marginEnd="8dp"
    android:layout_marginBottom="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.51"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/background"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"

        android:contentDescription="@string/camera"
        tools:srcCompat="@tools:sample/backgrounds/scenic" />

    <com.example.user.candleclub.DrawView
        android:id="@+id/DrawView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:background="@drawable/drawviewshape"/>
</FrameLayout>

这也如设计选项卡中所示,应该使CircleImageView和DrawView彼此重叠。但是,当我运行它时,它将CircleImageView置于DrawView下方。我怎样才能解决这个问题?我尝试使用布局边距,但似乎无济于事。有什么想法吗?

0 个答案:

没有答案