{"id":13644302,"url":"https://github.com/whilu/AndroidTagView","last_synced_at":"2025-04-21T07:30:46.749Z","repository":{"id":38362024,"uuid":"48808743","full_name":"whilu/AndroidTagView","owner":"whilu","description":"A TagView library for Android. Customize your own \u0026 Drag effect.","archived":false,"fork":false,"pushed_at":"2020-11-12T16:00:07.000Z","size":12218,"stargazers_count":1703,"open_issues_count":72,"forks_count":303,"subscribers_count":41,"default_branch":"master","last_synced_at":"2024-11-09T16:44:16.367Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/whilu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-30T16:13:51.000Z","updated_at":"2024-11-01T12:49:25.000Z","dependencies_parsed_at":"2022-07-12T17:27:47.850Z","dependency_job_id":null,"html_url":"https://github.com/whilu/AndroidTagView","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilu%2FAndroidTagView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilu%2FAndroidTagView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilu%2FAndroidTagView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilu%2FAndroidTagView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whilu","download_url":"https://codeload.github.com/whilu/AndroidTagView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250014576,"owners_count":21360977,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T01:02:00.981Z","updated_at":"2025-04-21T07:30:44.973Z","avatar_url":"https://github.com/whilu.png","language":"Java","readme":"# AndroidTagView\r\n\r\n[![Build Status](https://travis-ci.org/whilu/AndroidTagView.svg)](https://travis-ci.org/whilu/AndroidTagView) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-AndroidTagView-green.svg?style=true)](https://android-arsenal.com/details/1/2992)\r\n\r\nAn Android TagView library. You can customize awesome TagView by using this library.\r\n\r\n## Screenshots\r\n\r\n\u003cimg src=\"/screenshots/androidtagview_record_1.gif\" alt=\"androidtagview_record_1.gif\" title=\"androidtagview_record_1.gif\" width=\"400\" height=\"660\" /\u003e \u003cimg src=\"/screenshots/device-2016-11-09-223523.png\" alt=\"device-2016-11-09-223523.png\" title=\"device-2016-01-16-233617.png\" width=\"400\" height=\"660\" /\u003e\r\n\r\n## Usage\r\n\r\n### Step 1\r\n\r\nAdd below dependency in your **build.gradle** file.\r\n\r\n```groovy\r\ndependencies {\r\n    implementation 'co.lujun:androidtagview:1.1.7'\r\n    implementation 'androidx.appcompat:appcompat:1.0.1'\r\n}\r\n```\r\n\r\n### Step 2\r\n\r\nUse the AndroidTagView in layout file, you can add customized attributes here.\r\n\r\n```xml\r\n\u003cco.lujun.androidtagview.TagContainerLayout\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"wrap_content\"\r\n    android:layout_margin=\"0dp\"\r\n    android:padding=\"10dp\"\r\n    app:container_enable_drag=\"false\"\r\n    app:horizontal_interval=\"10dp\"\r\n    app:vertical_interval=\"10dp\"\r\n    app:tag_clickable=\"true\"\r\n    app:tag_theme=\"pure_teal\" /\u003e\r\n```\r\n\r\n### Step 3\r\n\r\nUse TagView in your code.\r\n\r\n```java\r\nTagContainerLayout mTagContainerLayout = (TagContainerLayout) findViewById(R.id.tagcontainerLayout);\r\nmTagContainerLayout.setTags(List\u003cString\u003e tags);\r\n```\r\n\r\nNow, you have successfully created some TagViews. The following will show some more useful features for you customize.\r\n\r\n## Attributes\r\n\r\n|name|format|description|\r\n|:---:|:---:|:---:|\r\n| vertical_interval | dimension | Vertical interval, default 5(dp)\r\n| horizontal_interval | dimension | Horizontal interval, default 5(dp)\r\n| container_border_width | dimension | TagContainerLayout border width(default 0.5dp)\r\n| container_border_radius | dimension | TagContainerLayout border radius(default 10.0dp)\r\n| container_border_color | color | TagContainerLayout border color(default #22FF0000)\r\n| container_background_color | color | TagContainerLayout background color(default #11FF0000)\r\n| container_enable_drag | boolean | Can drag TagView(default false)\r\n| container_drag_sensitivity | float | The sensitive of the ViewDragHelper(default 1.0f, normal)\r\n| container_gravity | enum | The TagContainerLayout [gravity](#gravity)\r\n| container_max_lines | integer | The max lines for TagContainerLayout(default 0, auto increase)\r\n| tag_border_width | dimension | TagView Border width(default 0.5dp)\r\n| tag_corner_radius | dimension | TagView Border radius(default 15.0dp)\r\n| tag_horizontal_padding | dimension | Horizontal padding for TagView, include left and right padding(left and right padding are equal, default 10dp)\r\n| tag_vertical_padding | dimension | Vertical padding for TagView, include top and bottom padding(top and bottom padding are equal, default 8dp)\r\n| tag_text_size | dimension | TagView Text size(default 14sp)\r\n| tag_bd_distance | dimension | The distance between baseline and descent(default 2.75dp)\r\n| tag_text_color | color | TagView text color(default #FF666666)\r\n| tag_border_color | color | TagView border color(default #88F44336)\r\n| tag_background_color | color | TagView background color(default #33F44336)\r\n| tag_max_length | integer | The max length for TagView(default max length 23)\r\n| tag_clickable | boolean | Whether TagView can clickable(default false)\r\n| tag_selectable | boolean | Whether TagView can be selectable(default false)\r\n| tag_theme | enum | The TagView [theme](#themes)\r\n| tag_text_direction | enum | The TagView text [direction](#directions)\r\n| tag_ripple_color | color | The ripple effect color(default #EEEEEE)\r\n| tag_ripple_alpha | integer | The ripple effect color alpha(the value may between 0 - 255, default 128)\r\n| tag_ripple_duration | integer | The ripple effect duration(In milliseconds, default 1000ms)\r\n| tag_enable_cross | boolean | Enable draw cross icon(default false)\r\n| tag_cross_width | dimension | The cross area width(your cross click area, default equal to the TagView's height)\r\n| tag_cross_color | color | The cross icon color(default Color.BLACK)\r\n| tag_cross_line_width | dimension | The cross line width(default 1dp)\r\n| tag_cross_area_padding | dimension | The padding of the cross area(default 10dp)\r\n| tag_support_letters_rlt | boolean | Whether to support 'letters show with RTL(eg: Android -\u003e diordnA)' style(default false)\r\n| tag_background | reference | TagView background resource(default none background)\r\n\r\n**You can set these attributes in layout file, or use setters(each attribute has get and set method) to set them.**\r\n\r\n## \u003cspan id=\"themes\"\u003eThemes\u003c/span\u003e\r\n\r\n|theme|code|value|description\r\n|:---:|:---:|:---:|:---:|\r\n| none | ColorFactory.NONE | -1 | **If you customize TagView with your way, set this theme**\r\n| random | ColorFactory.RANDOM | 0 | Create each TagView using random color\r\n| pure_cyan | ColorFactory.PURE_CYAN | 1 | All TagView created by pure cyan color\r\n| pure_teal | ColorFactory.PURE_TEAL | 2 | All TagView created by pure teal color\r\n\r\n## \u003cspan id=\"directions\"\u003eDirections\u003c/span\u003e\r\n\r\n|direction|code|value|description\r\n|:---:|:---:|:---:|:---:|\r\n| ltr | View.TEXT_DIRECTION_LTR | 3 | Text direction is forced to LTR(default)\r\n| rtl | View.TEXT_DIRECTION_RTL | 4 | Text direction is forced to RTL\r\n\r\n## \u003cspan id=\"gravity\"\u003eGravity\u003c/span\u003e\r\n\r\n|gravity|code|value|description\r\n|:---:|:---:|:---:|:---:|\r\n| left | Gravity.LEFT | 3 | Push TagView to the left of TagContainerLayout(default)\r\n| center | Gravity.CENTER | 17 | Push TagView to the center of TagContainerLayout\r\n| right | Gravity.RIGHT | 5 | Push TagView to the right of TagContainerLayout\r\n\r\n## \u003cspan id=\"Methods\"\u003eMethods\u003c/span\u003e\r\n\r\n* Set a ```TagView.OnTagClickListener``` for TagView, for ```onTagClick``` , ```onTagLongClick``` and ```onTagCrossClick``` callback\r\n```java\r\nmTagContainerLayout.setOnTagClickListener(new TagView.OnTagClickListener() {\r\n\r\n    @Override\r\n    public void onTagClick(int position, String text) {\r\n        // ...\r\n    }\r\n\r\n    @Override\r\n    public void onTagLongClick(final int position, String text) {\r\n        // ...\r\n    }\r\n\r\n    @Override\r\n    public void onSelectedTagDrag(int position, String text){\r\n        // ...\r\n    }\r\n    \r\n    @Override\r\n    public void onTagCrossClick(int position) {\r\n        // ...\r\n    }\r\n});\r\n```\r\n* Use ```setTagMaxLength(int max)``` to set text max length for all TagView.\r\n```java\r\nmTagContainerLayout.setTagMaxLength(int max);\r\n```\r\n* Use ```getTagText(int position)``` to get TagView text at the specified location.\r\n```java\r\nString text = mTagContainerLayout.getTagText(int position);\r\n```\r\n* ```getTags()``` return a string list for all tags in TagContainerLayout.\r\n```java\r\nList\u003cString\u003e list = mTagContainerLayout.getTags();\r\n```\r\n* If you set the attribute ```container_enable_drag``` to ```true```, when drag the TagView you can get latest state by using ```getTagViewState()```. There are 4 state:```ViewDragHelper.STATE_IDLE```, ```ViewDragHelper.STATE_DRAGGING```, and ```ViewDragHelper.STATE_SETTLING```.\r\n```java\r\nint state = mTagContainerLayout.getTagViewState();\r\n```\r\n* Set the [theme](#themes). If you want to customize theme, remember set theme with ```ColorFactory.NONE``` first, then set other attributes.\r\n```java\r\n// Set library provides theme\r\nmTagContainerLayout.setTheme(ColorFactory.PURE_CYAN);\r\n```\r\n```java\r\n// Set customize theme\r\nmTagContainerLayout.setTheme(ColorFactory.NONE);\r\nmTagContainerLayout.setTagBackgroundColor(Color.TRANSPARENT);\r\n```\r\n* Set the text [direction](#directions). The library support two direction ```View.TEXT_DIRECTION_LTR``` and ```View.TEXT_DIRECTION_RTL```.\r\n```java\r\nmTagContainerLayout.setTagTextDirection(View.TEXT_DIRECTION_RTL);\r\n```\r\n* Use ```setTagTypeface(Typeface typeface)``` to set TagView text typeface.\r\n```java\r\nTypeface typeface = Typeface.createFromAsset(getAssets(), \"iran_sans.ttf\");\r\nmTagContainerLayout.setTagTypeface(typeface);\r\n```\r\n\r\n**After set the attributes, set tags or add a tag.**\r\n\r\n* Use ```setTags()``` to set tags, require a parameter of type ```List\u003cString\u003e``` or ```String[]```.\r\n```java\r\nmTagContainerLayout.setTags(List\u003cString\u003e tags);\r\n```\r\n* Insert a TagView into ContainerLayout at the end.\r\n```java\r\nmTagContainerLayout.addTag(String text);\r\n```\r\n* Insert a TagView into ContainerLayout at the specified location, the TagView is inserted before the current element at the specified location.\r\n```java\r\nmTagContainerLayout.addTag(String text, int position);\r\n```\r\n* Remove TagView on particular position, require the position of the TagView.\r\n```java\r\nmTagContainerLayout.removeTag(int position);\r\n```\r\n* Remove all TagViews.\r\n```java\r\nmTagContainerLayout.removeAllTags();\r\n```\r\n* Get a TagView in specified position.\r\n```java\r\nmTagContainerLayout.getTagView(int position);\r\n```\r\n* Set color for each TagView.\r\n```java\r\nList\u003cint[]\u003e colors = new ArrayList\u003cint[]\u003e();\r\n//int[] color = {TagBackgroundColor, TabBorderColor, TagTextColor, TagSelectedBackgroundColor}\r\nint[] color1 = {Color.RED, Color.BLACK, Color.WHITE, Color.YELLOW};\r\nint[] color2 = {Color.BLUE, Color.BLACK, Color.WHITE, Color.YELLOW};\r\ncolors.add(color1);\r\ncolors.add(color2);\r\nmTagcontainerLayout.setTags(tags, colors);\r\n```\r\n\r\n## Change logs\r\n\r\n### 1.1.7(2019-01-21)\r\n- Fix bugs\r\n\r\n### 1.1.6(2018-12-1)\r\n- Support tag selectable\r\n\r\n### 1.1.5(2018-8-20)\r\n- Allow images on tags (in LTR languages).\r\n\r\n### 1.1.4(2017-6-1)\r\n- Add attribute for TagView background.\r\n\r\n### 1.1.3(2017-5-17)\r\n- Add ```getTagView(int position)``` method to get TagView in specified position.\r\n\r\n### 1.1.2(2017-5-16)\r\n- Fix bugs\r\n\r\n### 1.1.1(2017-4-16)\r\n- Customize the color of the TagView, see [#51](https://github.com/whilu/AndroidTagView/pull/51)\r\n- Fixed issue [#50](https://github.com/whilu/AndroidTagView/issues/50), [#49](https://github.com/whilu/AndroidTagView/issues/49)\r\n\r\n### 1.1.0(2017-3-5)\r\n- Fixed issue [#45](https://github.com/whilu/AndroidTagView/issues/45)\r\n- Support 'letters show with RTL(eg: Android -\u003e diordnA)' style\r\n\r\n### 1.0.6(2017-2-14)\r\n- Fix bugs\r\n\r\n### 1.0.5(2016-11-9)\r\n- Add cross view for TagView\r\n\r\n### 1.0.4(2016-10-30)\r\n- Support ripple effect(Call requires API level 11), like [Android CustomButton](https://github.com/whilu/AndroidSample/tree/master/CustomButton)\r\n- Fix bugs\r\n\r\n### 1.0.3(2016-4-3)\r\n- Add ```getTags()``` method to get the list for all tags\r\n- Fixed bugs in ListView/RecyclerView\r\n\r\n### 1.0.2(2016-1-18)\r\n- Support [gravity](#gravity) for ```TagContainerLayout```\r\n- Support set typeface\r\n\r\n### 1.0.1(2016-1-14)\r\n- Support text [direction](#directions)\r\n- Add ```removeAllTags()``` method for remove all TagViews\r\n- Fixed issue [#1](https://github.com/whilu/AndroidTagView/issues/1)\r\n- Fixed other bugs\r\n\r\n### 1.0.0(2016-1-6)\r\n- First release\r\n\r\n## Sample App\r\n[APK](/sample/sample-release.apk)\r\n\r\n## About\r\nIf you have any questions, contact me: [lujun.byte#gmail.com](mailto:lujun.byte@gmail.com).\r\n\r\n## License\r\n\r\n    Copyright 2015 lujun\r\n\r\n    Licensed under the Apache License, Version 2.0 (the \"License\");\r\n    you may not use this file except in compliance with the License.\r\n    You may obtain a copy of the License at\r\n\r\n     http://www.apache.org/licenses/LICENSE-2.0\r\n\r\n    Unless required by applicable law or agreed to in writing, software\r\n    distributed under the License is distributed on an \"AS IS\" BASIS,\r\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n    See the License for the specific language governing permissions and\r\n    limitations under the License.\r\n","funding_links":[],"categories":["Java","TagView","Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhilu%2FAndroidTagView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhilu%2FAndroidTagView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhilu%2FAndroidTagView/lists"}