今天我刚尝试使用来自Material设计的
ShapeableImageView
。<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/GuidelineTop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.15" />
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/imgProfile"
android:layout_width="150dp"
android:layout_height="150dp"
android:scaleType="centerCrop"
app:strokeColor="@color/grey400"
app:strokeWidth="@dimen/dp3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:adjustViewBounds="true"
app:layout_constraintTop_toBottomOf="@+id/GuidelineTop"
app:shapeAppearanceOverlay="@style/circleImageView" />
</androidx.constraintlayout.widget.ConstraintLayout>
我的圆形头像视图
<style name="circleImageView" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">50%</item>
</style>
这是一个样例截图。
正如您所见,描边在左侧、上方、右侧和底部被切掉了。我有什么遗漏吗?