AndroidTagView
介绍:
可自定义的标签视图,支持添加标签,点击,长按弹出删除对话框,以及拖拽排序。
运行效果:
使用说明:
第一步
在build.gradle 文件中添加以下依赖:
dependencies {
compile 'co.lujun:androidtagview:1.0.0'
}
第二步
在布局中使用AndroidTagView,你可以使用一些我们自定义的属性。
<co.lujun.androidtagview.TagContainerLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:padding="10dp"
app:container_enable_drag="false"
app:horizontal_interval="10dp"
app:vertical_interval="10dp"
app:tag_clickable="true"
app:tag_theme="pure_teal" />
第三步
在代码中使用TagView。
TagContainerLayout mTagContainerLayout = (TagContainerLayout) findViewById(R.id.tagcontainerLayout);
mTagContainerLayout.setTags(List<String> tags);
现在,你已经成功的创建了一些标签,下面将演示更多的自定义功能。
属性
name | format | description |
---|---|---|
vertical_interval | dimension | Vertical interval, default 5(dp) |
horizontal_interval | dimension | Horizontal interval, default 5(dp) |
container_border_width | dimension | TagContainerLayout border width(default 0.5dp) |
container_border_radius | dimension | TagContainerLayout border radius(default 10.0dp) |
container_border_color | color | TagContainerLayout border color(default #22FF0000) |
container_background_color | color | TagContainerLayout background color(default #11FF0000) |
container_enable_drag | boolean | Can drag TagView(default false) |
container_drag_sensitivity | float | The sensitive of the ViewDragHelper(default 1.0f, normal) |
tag_border_width | dimension | TagView Border width(default 0.5dp) |
tag_corner_radius | dimension | TagView Border radius(default 15.0dp) |
tag_horizontal_padding | dimension | Horizontal padding for TagView, include left and right padding(left and right padding are equal, default 20px) |
tag_vertical_padding | dimension | Vertical padding for TagView, include top and bottom padding(top and bottom padding are equal, default 17px) |
tag_text_size | dimension | TagView Text size(default 14sp) |
tag_text_color | color | TagView text color(default #FF666666) |
tag_border_color | color | TagView border color(default #88F44336) |
tag_background_color | color | TagView background color(default #33F44336) |
tag_max_length | integer | The max length for TagView(default max length 23) |
tag_clickable | boolean | Whether TagView can clickable(default unclickable) |
tag_theme | enum | The TagView theme |
你可以在布局文件中设置这些属性,或者使用setters方法来设置。
主题
theme | code | description |
---|---|---|
none | ColorFactory.NONE | If you customize TagView with your way, set this theme |
random | ColorFactory.RANDOM | Create each TagView using random color |
pure_cyan | ColorFactory.PURE_CYAN | All TagView created by pure cyan color |
pure_teal | ColorFactory.PURE_TEAL | All TagView created by pure teal color |
已下载
0