在Android实现圆形图像的自定义视图:CircularImageView

jopen 10年前

用于在Android应用中生成自定义圆形图像视图的同时保持最佳画面性能。
687474703a2f2f692e696d6775722e636f6d2f51333365325a622e676966.gif

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 false
  • app:border_color (color) -> default WHITE
  • app:border_width (dimension) -> default 2dp
  • app:selector (boolean) -> default false
  • app:selector_color (color) -> default TRANSPARENT
  • app:selector_stroke_color (color) -> default BLUE
  • app:selector_stroke_width (dimension) -> default 2dp
  • app: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();

项目主页:http://www.open-open.com/lib/view/home/1410400532445