app:strokeWidth=“4dp” />
-
app:strokeColor 描边颜色
-
app:strokeWidth 描边宽度
-
注意这里padding的数值是描边宽度的一半,后面会说
切角
<com.google.android.material.imageview.ShapeableImageView
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_margin=“10dp”
android:padding=“2dp”
android:src="@mipmap/ic_avatar"
app:shapeAppearance="@style/CutStyle"
app:strokeColor="@color/red"
app:strokeWidth=“4dp” />
- cornerFamily:cut 处理模式变为裁剪
菱形
<com.google.android.material.imageview.ShapeableImageView
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_margin=“10dp”
android:padding=“2dp”
android:src="@mipmap/ic_avatar"
app:shapeAppearance="@style/RhombusStyle"
app:strokeColor="@color/red"
app:strokeWidth=“4dp” />
- 同样,裁剪模式下圆角大小也可以计算
叶子
<com.google.android.material.imageview.ShapeableImageView
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_margin=“10dp”
android:padding=“2dp”
android:src="@mipmap/ic_avatar"
app:shapeAppearance="@style/LeafStyle"
app:strokeColor="@color/red"
app:strokeWidth=“4dp” />
-
cornerSizeTopLeft 左上圆角
-
cornerSizeBottomRight 右下圆角
-
以此类推,左上、左下、右上、右下等
半圆
<com.google.android.material.imageview.ShapeableImageView
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_margin=“10dp”
android:padding=“2dp”
android:src="@mipmap/ic_avatar"
app:shapeAppearance="@style/SemicircleStyle"
app:strokeColor="@color/red"
app:strokeWidth=“4dp” />