在Android实现圆形图像的自定义视图:CircularImageView
jopen
10年前
用于在Android应用中生成自定义圆形图像视图的同时保持最佳画面性能。
XML
<com.pkmmte.view.CircularImageView android:layout_width="250dp" android:layout_height="250dp" android:src="@drawable/image" app:border_color="#EEEEEE" app:border_width="4dp" app:shadow="true" />
You may use the following properties in your XML to customize your CircularImageView.
Properties:
app:border
(boolean) -> default falseapp:border_color
(color) -> default WHITEapp:border_width
(dimension) -> default 2dpapp:selector
(boolean) -> default falseapp:selector_color
(color) -> default TRANSPARENTapp:selector_stroke_color
(color) -> default BLUEapp:selector_stroke_width
(dimension) -> default 2dpapp:shadow
(boolean) -> default false
JAVA
CircularImageView circularImageView = (CircularImageView)findViewById(R.id.yourCircularImageView); circularImageView.setBorderColor(getResources().getColor(R.color.GrayLight)); circularImageView.setBorderWidth(10); circularImageView.setSelectorColor(getResources().getColor(R.color.BlueLightTransparent)); circularImageView.setSelectorStrokeColor(getResources().getColor(R.color.BlueDark)); circularImageView.setSelectorStrokeWidth(10); circularImageView.addShadow();