如何使正方形成为弧形边界?

时间:2020-03-12 11:15:35

标签: java android android-layout shapes

enter image description here

我想在Android中制作这种弧形正方形边框。这个想法是设置图像的边框,只有内部图片会像遮罩一样显示。外部图片将被裁剪或不显示

我尝试了很多方法,但无法解决此问题。

任何帮助将不胜感激!

2 个答案:

答案 0 :(得分:0)

您可以使用“画布”中的list(filter(lambda x: x[1]>=1000, fd_1.items()))drawLine()函数来逐段绘制。 您可以检查如何使用此here

答案 1 :(得分:0)

尝试一下

  1. 您可以通过Canvas来实现。

    请仔细绘制所需的形状

  2. 您可以使用库android-shape-imageview

     <com.github.siyamed.shapeimageview.mask.PorterShapeImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:siShape="@drawable/shape_bg"
        android:src="@drawable/face"
        app:siSquare="true"/>
    

使用库的输出看起来像

enter image description here

通过替换 ImageView

中的 siShape ,您可以获得不同的形状

enter image description here