首页 > 解决方案 > 如何使用三个角和阴影制作图像视图

问题描述

图片

如何制作像这样只有三个角的图像我尝试使用框架布局插入图像视图并使其成为原始图像的资源添加另一个具有 3 个角的边框 src 的图像视图但它不起作用

标签: androidxmlimageviewmaterial-components-android

解决方案


借助材料组件库,您可以使用MaterialShapeDrawable.

只需使用类似的东西:

  <com.google.android.material.imageview.ShapeableImageView
      app:shapeAppearanceOverlay="@style/onlyonecorner"
      app:srcCompat="@drawable/xxx"
      ../>

和:

  <style name="onlyonecorner">
    <item name="cornerFamily">rounded</item>
    <item name="cornerSize">50%</item>
    <item name="cornerSizeTopRight">0dp</item>
  </style>

在此处输入图像描述

ShapeableImageView需要最低1.2.0-alpha03版本。


推荐阅读