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

可以用作自定义的属性

attrvalue/exampledescription
show_bordertrueshows or hides each region borders
border_color#fffsets all borders color
border_width5sets borders width
border_roundtruemakes border corners round
generation_typerandomsets different points generation behavior

Generation types

typedescription
randomVoronoiView generates a random point positions inside the view bounds.
orderedpoints are placed like a table - rows and columns.
custompoints will be placed in user defined positions.

这些属性也可以通过代码设置。

已下载
0