Vorolay
介绍:
一个将子view显示为多边形图案的布局。
运行效果:
使用说明:
在项目的build.gradle中加入如下代码:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
在相应的模块的build.gradle中加入如下代码:
dependencies {
compile 'com.github.Quatja:Vorolay:1.0.1'
}
把VoronoiView添加到布局中。你可以使用xml属性来自定义它
<quatja.com.vorolay.VoronoiView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="50dp"
custom:border_color="@color/gray"
custom:border_round="false"
custom:border_width="5" />
然后把子view添加到VoronoiView中
VoronoiView voronoiView = (VoronoiView) findViewById(R.id.voronoi);
LayoutInflater layoutInflater = getLayoutInflater();
for (int i = 0; i < 15; i++) {
View view = layoutInflater.inflate(R.layout.item_voronoi, null, false);
voronoiView.addView(view);
}
Customization
可以用作自定义的属性
attr | value/example | description |
---|---|---|
show_border | true | shows or hides each region borders |
border_color | #fff | sets all borders color |
border_width | 5 | sets borders width |
border_round | true | makes border corners round |
generation_type | random | sets different points generation behavior |
Generation types
type | description |
---|---|
random | VoronoiView generates a random point positions inside the view bounds. |
ordered | points are placed like a table - rows and columns. |
custom | points will be placed in user defined positions. |
这些属性也可以通过代码设置。
已下载
0