将圆形ImageView连续放置在另一个上

问题描述 投票:0回答:1

创建彼此对称的圆形图像的最佳方法是什么,如下所示。

enter image description here

是否有任何库或任何自定义小部件?还是我们可以使用ConstraintLayout来做到这一点?

android android-layout
1个回答
0
投票

使用this库,您可以制作圆形视图

enter image description here

<com.github.florent37.shapeofview.shapes.CircleView
    android:layout_width="150dp"
    android:layout_height="150dp"

    android:elevation="4dp"
    app:shape_circle_borderColor="@android:color/black"
    app:shape_circle_borderWidth="2dp">

        <!-- YOUR CONTENT -->

 </com.github.florent37.shapeofview.shapes.CircleView>

Secend Step以线性布局添加所有圆视图,并将负边距设置为低于viwe,例如我使用图像视图

    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">

    <ImageView
        android:id="@+id/imageView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        tools:srcCompat="@tools:sample/avatars" />

    <ImageView
        android:id="@+id/imageView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="-30dp"
        tools:srcCompat="@tools:sample/avatars" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="-30dp"
        tools:srcCompat="@tools:sample/avatars" />
</LinearLayout>
© www.soinside.com 2019 - 2024. All rights reserved.