PolygonImageView
介绍:
多边形、圆形效果的自定义ImageView
运行效果:
使用说明:
XML
<net.grobas.view.PolygonImageView
android:layout_width="250dp"
android:layout_height="250dp"
android:src="@drawable/cat07"
app:poly_shadow="true"
app:poly_shadow_color="@android:color/black"
app:poly_border="true"
app:poly_border_color="@android:color/white"
app:poly_vertices="6"
app:poly_border_width="5dp"
app:poly_corner_radius="5"
app:poly_rotation_angle="25" />
属性:
app:poly_vertices (integer) -> 默认 5
0 -> Circle
1 -> Regular ImageView, no affected by other properties
2 -> Square
>2 -> Polygon form
app:poly_shadow (boolean) -> 默认 false
app:poly_shadow_color (color) -> 默认 Black
app:poly_border (boolean) -> 默认 false
app:poly_border_color (color) -> 默认 White
app:poly_border_width (dimension) -> 默认 4dp
app:poly_corner_radius (float) -> 默认 0.0f
app:poly_rotation_angle (float) -> 默认 0.0f
JAVA
LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
PolygonImageView view = new PolygonImageView(this);
view.setImageResource(R.drawable.cat01);
view.addShadow(7.5f, 0f, 7.5f, Color.RED);
view.setBorder(true);
view.setBorderWidth(5);
view.setCornerRadius(5);
view.setBorderColorResource(android.R.color.white);
view.setVertices(6);
view.setPolygonShape(new StarPolygonShape(0.8f, false));
layout.addView(view);
效果
有三种基本效果:
-
RegularPolygonShape
-
PaperPolygonShape
-
StarPolygonShape
可以重写BasePolygonShape或者interface PolygonShape来创建你自己的效果
已下载
0