├── .gitignore ├── README.md ├── build.gradle ├── demo ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── jude │ │ └── tagviewdemo │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── jude │ │ │ └── tagviewdemo │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-xxhdpi │ │ ├── ic_certification.png │ │ ├── ic_doctor.png │ │ ├── ic_driver.png │ │ ├── ic_factory.png │ │ ├── ic_female.png │ │ ├── ic_hospital.png │ │ ├── ic_law.png │ │ ├── ic_male.png │ │ └── ic_teacher.png │ │ ├── layout │ │ └── activity_main.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── jude │ └── tagview │ └── ExampleUnitTest.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── image.png ├── settings.gradle └── tagview ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src ├── androidTest └── java │ └── com │ └── jude │ └── tagview │ └── ApplicationTest.java ├── main ├── AndroidManifest.xml ├── java │ └── com │ │ └── jude │ │ └── tagview │ │ └── TAGView.java └── res │ ├── layout │ └── tag_view.xml │ └── values │ ├── attrs.xml │ └── strings.xml └── test └── java └── com └── jude └── tagview └── ExampleUnitTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .gradle 3 | .DS_Store 4 | /captures 5 | 6 | # built application files 7 | *.apk 8 | 9 | # files for the dex VM 10 | *.dex 11 | 12 | # Java class files 13 | *.class 14 | 15 | # generated files 16 | bin/ 17 | gen/ 18 | build 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Eclipse project files 24 | .classpath 25 | .project 26 | 27 | # Proguard folder generated by Eclipse 28 | proguard/ 29 | 30 | # Intellij project files 31 | *.iml 32 | *.ipr 33 | *.iws 34 | .idea 35 | 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TAGView 2 | Simple android view to display colorful tag efficiently. 3 | ![image](image.png) 4 | 5 | ## Dependency 6 | `compile 'com.jude:tagview:2.1.6'` 7 | 8 | ## Usage 9 | 10 | 29 | 30 | All properties in the xml can be set in the code. 31 | 32 | License 33 | ------- 34 | 35 | Copyright 2018 Jude 36 | 37 | Licensed under the Apache License, Version 2.0 (the "License"); 38 | you may not use this file except in compliance with the License. 39 | You may obtain a copy of the License at 40 | 41 | http://www.apache.org/licenses/LICENSE-2.0 42 | 43 | Unless required by applicable law or agreed to in writing, software 44 | distributed under the License is distributed on an "AS IS" BASIS, 45 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 46 | See the License for the specific language governing permissions and 47 | limitations under the License. 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | mavenCentral() 6 | jcenter() 7 | google() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.0.0-beta2' 11 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' 12 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' 13 | 14 | // NOTE: Do not place your application dependencies here; they belong 15 | // in the individual module build.gradle files 16 | } 17 | } 18 | 19 | allprojects { 20 | repositories { 21 | mavenCentral() 22 | jcenter() 23 | google() 24 | maven { url "https://jitpack.io" } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /demo/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion "26.0.1" 6 | 7 | defaultConfig { 8 | applicationId "com.jude.tagview" 9 | minSdkVersion 15 10 | targetSdkVersion 26 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | testCompile 'junit:junit:4.12' 24 | compile 'com.android.support:appcompat-v7:26.0.1' 25 | compile 'com.github.romainguy:ViewServer:master' 26 | compile project(':tagview') 27 | } 28 | -------------------------------------------------------------------------------- /demo/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in F:\software\android-sdk_r24.0.2-windows\android-sdk-windows/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /demo/src/androidTest/java/com/jude/tagviewdemo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.jude.tagviewdemo; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /demo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /demo/src/main/java/com/jude/tagviewdemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.jude.tagviewdemo; 2 | 3 | import android.graphics.Color; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.LinearLayout; 9 | 10 | import com.jude.tagview.TAGView; 11 | 12 | public class MainActivity extends AppCompatActivity { 13 | private TAGView view; 14 | private TAGView cer; 15 | private LinearLayout container; 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_main); 21 | 22 | TAGView cer = (TAGView) findViewById(R.id.tag_certification_radius); 23 | cer.setRadius(dip2px(8)); 24 | 25 | TAGView cer2 = (TAGView) findViewById(R.id.tag_certification_stroke); 26 | cer2.setStrokeWidth(dip2px(2)); 27 | 28 | view = (TAGView) findViewById(R.id.tag_text); 29 | view.setText("FB 的終極野心:用手機端智慧管家 M 取代 Google 大神的搜尋地位"); 30 | view.setOnClickListener(new View.OnClickListener() { 31 | @Override 32 | public void onClick(View v) { 33 | view.setText("COOL"); 34 | } 35 | }); 36 | 37 | container = findViewById(R.id.container); 38 | 39 | TAGView tagView = new TAGView(this); 40 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, dip2px(28)); 41 | params.setMargins(dip2px(16), 0, 0, 0); 42 | tagView.setLayoutParams(params); 43 | tagView.setPadding(dip2px(16), 0, dip2px(16), 0); 44 | tagView.setText("接受"); 45 | tagView.setTextColor(Color.GRAY); 46 | tagView.setBackgroundColor(Color.GRAY); 47 | tagView.setStrokeWidth(dip2px(1)); 48 | tagView.setRadius(dip2px(16)); 49 | container.addView(tagView); 50 | } 51 | 52 | public int dip2px(float dpValue) { 53 | final float scale = getResources().getDisplayMetrics().density; 54 | return (int) (dpValue * scale + 0.5f); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xxhdpi/ic_certification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/TAGView/444c5c63a4be6dae56c4adc133b76d2b60bb8043/demo/src/main/res/drawable-xxhdpi/ic_certification.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xxhdpi/ic_doctor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/TAGView/444c5c63a4be6dae56c4adc133b76d2b60bb8043/demo/src/main/res/drawable-xxhdpi/ic_doctor.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xxhdpi/ic_driver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/TAGView/444c5c63a4be6dae56c4adc133b76d2b60bb8043/demo/src/main/res/drawable-xxhdpi/ic_driver.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xxhdpi/ic_factory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/TAGView/444c5c63a4be6dae56c4adc133b76d2b60bb8043/demo/src/main/res/drawable-xxhdpi/ic_factory.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xxhdpi/ic_female.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/TAGView/444c5c63a4be6dae56c4adc133b76d2b60bb8043/demo/src/main/res/drawable-xxhdpi/ic_female.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xxhdpi/ic_hospital.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/TAGView/444c5c63a4be6dae56c4adc133b76d2b60bb8043/demo/src/main/res/drawable-xxhdpi/ic_hospital.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xxhdpi/ic_law.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/TAGView/444c5c63a4be6dae56c4adc133b76d2b60bb8043/demo/src/main/res/drawable-xxhdpi/ic_law.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xxhdpi/ic_male.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/TAGView/444c5c63a4be6dae56c4adc133b76d2b60bb8043/demo/src/main/res/drawable-xxhdpi/ic_male.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xxhdpi/ic_teacher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/TAGView/444c5c63a4be6dae56c4adc133b76d2b60bb8043/demo/src/main/res/drawable-xxhdpi/ic_teacher.png -------------------------------------------------------------------------------- /demo/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 8 | 12 | 20 | 30 | 41 | 42 | 46 | 55 | 65 | 76 | 77 | 81 | 82 | 89 | 90 | 97 | 98 | 106 | 107 | 108 | 109 | 113 | 114 | 120 | 127 | 128 | 135 | 142 | 143 | 151 | 159 | 160 | 161 | 165 | 173 | 174 | 175 | 176 | 177 | 178 | 183 | 184 | 194 | 195 | 205 | 206 | 216 | 217 | 218 | 219 | 220 | 226 | 227 | 228 | -------------------------------------------------------------------------------- /demo/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/TAGView/444c5c63a4be6dae56c4adc133b76d2b60bb8043/demo/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/TAGView/444c5c63a4be6dae56c4adc133b76d2b60bb8043/demo/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/TAGView/444c5c63a4be6dae56c4adc133b76d2b60bb8043/demo/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/TAGView/444c5c63a4be6dae56c4adc133b76d2b60bb8043/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /demo/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /demo/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | TAGView 3 | 4 | Hello world! 5 | Settings 6 | 7 | -------------------------------------------------------------------------------- /demo/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /demo/src/test/java/com/jude/tagview/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.jude.tagviewdemo; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ## Project-wide Gradle settings. 2 | # 3 | # For more details on how to configure your build environment visit 4 | # http://www.gradle.org/docs/current/userguide/build_environment.html 5 | # 6 | # Specifies the JVM arguments used for the daemon process. 7 | # The setting is particularly useful for tweaking memory settings. 8 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 10 | # 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true 15 | #Mon Sep 21 21:10:46 CST 2015 16 | 17 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/TAGView/444c5c63a4be6dae56c4adc133b76d2b60bb8043/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Aug 23 09:58:17 CST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip 7 | 8 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jude95/TAGView/444c5c63a4be6dae56c4adc133b76d2b60bb8043/image.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':demo', ':tagview' 2 | -------------------------------------------------------------------------------- /tagview/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /tagview/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion "26.0.1" 6 | 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 26 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | testCompile 'junit:junit:4.12' 23 | compile 'com.android.support:appcompat-v7:26.0.1' 24 | } 25 | 26 | ext { 27 | bintrayRepo = 'maven'////bintray上的仓库名,一般为maven 28 | bintrayName = 'tagview'//bintray上的项目名 29 | 30 | publishedGroupId = 'com.jude'//JCenter的GroupId 31 | artifact = 'tagview'//JCenter的ArtifactId 32 | 33 | siteUrl = 'https://github.com/Jude95/TAGView' 34 | gitUrl = 'https://github.com/Jude95/TAGView' 35 | 36 | libraryVersion = '2.1.6'//版本号 37 | libraryName = 'tagview'//项目名字,没什么用 38 | libraryDescription = 'A tool for Android'//项目描述,没什么用 39 | 40 | //开发者信息 41 | developerId = 'jude95' 42 | developerName = 'jude95' 43 | developerEmail = 'jude@helloworld.moe' 44 | 45 | //以上所有信息自行修改,以下不变 46 | 47 | licenseName = 'The Apache Software License, Version 2.0' 48 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' 49 | allLicenses = ["Apache-2.0"] 50 | } 51 | apply from:'https://raw.githubusercontent.com/Jude95/JCenter/master/install.gradle' 52 | apply from:'https://raw.githubusercontent.com/Jude95/JCenter/master/bintray.gradle' 53 | -------------------------------------------------------------------------------- /tagview/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in F:\software\android-sdk_r24.0.2-windows\android-sdk-windows/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /tagview/src/androidTest/java/com/jude/tagview/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.jude.tagview; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /tagview/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /tagview/src/main/java/com/jude/tagview/TAGView.java: -------------------------------------------------------------------------------- 1 | package com.jude.tagview; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.graphics.Color; 7 | import android.graphics.Paint; 8 | import android.graphics.RectF; 9 | import android.util.AttributeSet; 10 | import android.util.TypedValue; 11 | import android.view.LayoutInflater; 12 | import android.view.ViewGroup; 13 | import android.widget.ImageView; 14 | import android.widget.TextView; 15 | 16 | /** 17 | * Created by Mr.Jude on 2015/8/15. 18 | */ 19 | public class TAGView extends ViewGroup { 20 | 21 | private ImageView mImageView; 22 | private TextView mTextView; 23 | 24 | 25 | private float radius; 26 | 27 | private Paint mPaint; 28 | private int color; 29 | private int imageWidth; 30 | private int dividerWidth; 31 | private int paddingLeft; 32 | private int paddingTop; 33 | private int paddingBottom; 34 | private int paddingRight; 35 | private int strokeWidth; 36 | private boolean asCircle; 37 | 38 | public TAGView(Context context) { 39 | this(context,null); 40 | } 41 | 42 | public TAGView(Context context, AttributeSet attrs) { 43 | this(context, attrs, 0); 44 | } 45 | 46 | public TAGView(Context context, AttributeSet attrs, int defStyleAttr) { 47 | super(context, attrs, defStyleAttr); 48 | init(attrs); 49 | } 50 | 51 | public void init(AttributeSet attrs){ 52 | setWillNotDraw(false); 53 | mPaint = new Paint(); 54 | mPaint.setAntiAlias(true); 55 | mPaint.setStyle(Paint.Style.FILL_AND_STROKE); 56 | LayoutInflater.from(getContext()).inflate(R.layout.tag_view,this,true); 57 | mImageView = (ImageView) findViewById(R.id.icon); 58 | mTextView = (TextView) findViewById(R.id.text); 59 | 60 | TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TAGView); 61 | try { 62 | setIcon(a.getResourceId(R.styleable.TAGView_tag_icon, 0)); 63 | setText(a.getString(R.styleable.TAGView_tag_text)); 64 | setTextColor(a.getColor(R.styleable.TAGView_tag_text_color, Color.WHITE)); 65 | color = a.getColor(R.styleable.TAGView_tag_color, Color.RED); 66 | mPaint.setColor(color); 67 | radius = a.getDimension(R.styleable.TAGView_tag_radius, dip2px(2)); 68 | imageWidth = (int) a.getDimension(R.styleable.TAGView_tag_image_width, dip2px(16)); 69 | dividerWidth = (int) a.getDimension(R.styleable.TAGView_tag_divider, dip2px(2)); 70 | paddingLeft=paddingRight=paddingTop=paddingBottom 71 | =(int) a.getDimension(R.styleable.TAGView_tag_padding, dip2px(2)); 72 | paddingLeft = (int) a.getDimension(R.styleable.TAGView_tag_padding_left, dip2px(4)); 73 | paddingRight = (int) a.getDimension(R.styleable.TAGView_tag_padding_right, dip2px(4)); 74 | paddingTop = (int) a.getDimension(R.styleable.TAGView_tag_padding_top, dip2px(2)); 75 | paddingBottom = (int) a.getDimension(R.styleable.TAGView_tag_padding_bottom, dip2px(2)); 76 | asCircle = a.getBoolean(R.styleable.TAGView_tag_as_circle,false); 77 | strokeWidth = (int) a.getDimension(R.styleable.TAGView_tag_stroke_width, dip2px(0)); 78 | setStrokeWidth(strokeWidth); 79 | 80 | int textSize = a.getDimensionPixelSize(R.styleable.TAGView_tag_text_size, (int) TypedValue.applyDimension( 81 | TypedValue.COMPLEX_UNIT_SP, 13, getResources().getDisplayMetrics())); 82 | mTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX,textSize); 83 | }finally { 84 | a.recycle(); 85 | } 86 | } 87 | 88 | @Override 89 | public void setPadding(int left, int top, int right, int bottom) { 90 | paddingLeft = left; 91 | paddingRight = right; 92 | paddingTop = top; 93 | paddingBottom = bottom; 94 | requestLayout(); 95 | } 96 | 97 | public void setDividerWidth(int width){ 98 | dividerWidth = width; 99 | requestLayout(); 100 | } 101 | 102 | public void setImageWidth(int width){ 103 | imageWidth = width; 104 | invalidate(); 105 | } 106 | 107 | public void setAsCircle(){ 108 | asCircle = true; 109 | invalidate(); 110 | } 111 | 112 | public void setRadius(int radius){ 113 | this.radius = radius; 114 | invalidate(); 115 | } 116 | 117 | public void setStrokeWidth(int width){ 118 | strokeWidth = width; 119 | if (strokeWidth != 0){ 120 | mPaint.setStyle(Paint.Style.STROKE); 121 | mPaint.setStrokeWidth(strokeWidth); 122 | mPaint.setStrokeJoin(Paint.Join.ROUND); 123 | mPaint.setStrokeCap(Paint.Cap.ROUND); 124 | }else{ 125 | mPaint.setStyle(Paint.Style.FILL); 126 | } 127 | invalidate(); 128 | } 129 | 130 | public void setTextSize(int sp){ 131 | mTextView.setTextSize(sp); 132 | } 133 | 134 | 135 | public void setText(String text){ 136 | if (text==null||text.isEmpty()){ 137 | mTextView.setVisibility(GONE); 138 | } 139 | else{ 140 | mTextView.setVisibility(VISIBLE); 141 | mTextView.setText(text); 142 | } 143 | } 144 | public void setTextColor(int color){ 145 | mTextView.setTextColor(color); 146 | } 147 | public void setIcon(int res){ 148 | if (res == 0)removeIcon(); 149 | else { 150 | mImageView.setVisibility(VISIBLE); 151 | mImageView.setImageResource(res); 152 | } 153 | } 154 | 155 | public void removeIcon(){ 156 | mImageView.setVisibility(GONE); 157 | } 158 | 159 | public void setBackgroundColor(int color){ 160 | mPaint.setColor(color); 161 | invalidate(); 162 | } 163 | 164 | @Override 165 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 166 | //super.onMeasure(widthMeasureSpec,heightMeasureSpec); 167 | int width = MeasureSpec.getSize(widthMeasureSpec); 168 | int widthModel = MeasureSpec.getMode(widthMeasureSpec); 169 | int height = MeasureSpec.getSize(heightMeasureSpec); 170 | int heightModel = MeasureSpec.getMode(heightMeasureSpec); 171 | 172 | 173 | int inWidth = width-paddingLeft-paddingRight; 174 | int inHeight = height-paddingTop-paddingBottom; 175 | 176 | // switch (widthModel){ 177 | // case MeasureSpec.EXACTLY: 178 | // Log.i("TAGView",mTextView.getText()+" widthModel"+" EXACTLY"+" width"+width); 179 | // break; 180 | // case MeasureSpec.UNSPECIFIED: 181 | // Log.i("TAGView",mTextView.getText()+" widthModel"+" UNSPECIFIED"+" width"+width); 182 | // break; 183 | // case MeasureSpec.AT_MOST: 184 | // Log.i("TAGView",mTextView.getText()+" widthModel"+" AT_MOST"+" width"+width); 185 | // break; 186 | // } 187 | // switch (heightModel){ 188 | // case MeasureSpec.EXACTLY: 189 | // Log.i("TAGView",mTextView.getText()+" heightModel"+" EXACTLY"+" height"+height); 190 | // break; 191 | // case MeasureSpec.UNSPECIFIED: 192 | // Log.i("TAGView",mTextView.getText()+" heightModel"+" UNSPECIFIED"+" height"+height); 193 | // break; 194 | // case MeasureSpec.AT_MOST: 195 | // Log.i("TAGView",mTextView.getText()+" heightModel"+" AT_MOST"+" height"+height); 196 | // break; 197 | // } 198 | 199 | if (mImageView.getVisibility()==VISIBLE) 200 | mImageView.measure( 201 | MeasureSpec.makeMeasureSpec(imageWidth,MeasureSpec.EXACTLY), 202 | MeasureSpec.makeMeasureSpec(inHeight,MeasureSpec.UNSPECIFIED) 203 | ); 204 | if (mTextView.getVisibility()==VISIBLE) 205 | mTextView.measure( 206 | MeasureSpec.makeMeasureSpec(inWidth,MeasureSpec.UNSPECIFIED), 207 | MeasureSpec.makeMeasureSpec(inHeight,MeasureSpec.UNSPECIFIED) 208 | ); 209 | 210 | // Log.i("TAGView",mTextView.getText()+" I width"+mImageView.getMeasuredWidth()+" I height"+mImageView.getMeasuredHeight()+" T width"+mTextView.getMeasuredWidth()+" T height"+mTextView.getMeasuredHeight()); 211 | 212 | int widthTotal = mImageView.getMeasuredWidth()+ 213 | mTextView.getMeasuredWidth()+ 214 | paddingLeft+ 215 | paddingRight+ 216 | ((mTextView.getVisibility()==VISIBLE && mImageView.getVisibility()==VISIBLE)?dividerWidth:0); 217 | int heightTotal = Math.max(mImageView.getMeasuredHeight(), mTextView.getMeasuredHeight())+paddingTop+paddingBottom; 218 | 219 | 220 | 221 | int reheight = height; 222 | int rewidth = width; 223 | switch (heightModel){ 224 | case MeasureSpec.EXACTLY: 225 | reheight = height; 226 | break; 227 | case MeasureSpec.AT_MOST: 228 | reheight = Math.min(heightTotal, height); 229 | break; 230 | case MeasureSpec.UNSPECIFIED: 231 | reheight = heightTotal; 232 | break; 233 | } 234 | switch (widthModel){ 235 | case MeasureSpec.EXACTLY: 236 | rewidth = width; 237 | break; 238 | case MeasureSpec.AT_MOST: 239 | rewidth = Math.min(widthTotal, width); 240 | break; 241 | case MeasureSpec.UNSPECIFIED: 242 | rewidth = heightTotal; 243 | break; 244 | } 245 | setMeasuredDimension(rewidth, reheight); 246 | } 247 | 248 | 249 | @Override 250 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { 251 | int width = right - left,height = bottom - top; 252 | // Log.i("TAGView", mTextView.getText() + " Layout W" + width); 253 | int l = paddingLeft,r = width-paddingRight,t = paddingTop,b = height-paddingBottom; 254 | int centerVertical = (b+t)/2 , centerHorizontal = (l+r)/2; 255 | 256 | 257 | 258 | if (mTextView.getVisibility()==VISIBLE&&mImageView.getVisibility()==VISIBLE){ 259 | int divider = Math.max(r - l - mImageView.getMeasuredWidth() - mTextView.getMeasuredWidth() - dividerWidth, 0)/3; 260 | 261 | mImageView.layout( 262 | l+divider, 263 | centerVertical-mImageView.getMeasuredHeight()/2, 264 | l+divider+mImageView.getMeasuredWidth(), 265 | centerVertical+mImageView.getMeasuredHeight()/2); 266 | 267 | mTextView.layout( 268 | l+divider*2+mImageView.getMeasuredWidth()+dividerWidth, 269 | centerVertical-mTextView.getMeasuredHeight()/2, 270 | r-divider, 271 | centerVertical+mTextView.getMeasuredHeight()/2); 272 | }else { 273 | 274 | mImageView.layout( 275 | centerHorizontal-mImageView.getMeasuredWidth()/2, 276 | centerVertical-mImageView.getMeasuredHeight()/2, 277 | centerHorizontal+mImageView.getMeasuredWidth() / 2, 278 | centerVertical + mImageView.getMeasuredHeight()/2); 279 | 280 | mTextView.layout( 281 | centerHorizontal-mTextView.getMeasuredWidth()/2, 282 | centerVertical-mTextView.getMeasuredHeight()/2, 283 | centerHorizontal+mTextView.getMeasuredWidth()/2, 284 | centerVertical+mTextView.getMeasuredHeight()/2); 285 | } 286 | 287 | } 288 | 289 | 290 | @Override 291 | public void draw(Canvas canvas) { 292 | if (asCircle){ 293 | canvas.drawArc(new RectF(strokeWidth/2, strokeWidth/2, getWidth()-strokeWidth/2, getHeight()-strokeWidth/2),0,360,true,mPaint); 294 | }else { 295 | canvas.drawRoundRect(new RectF(strokeWidth/2, strokeWidth/2, getWidth()-strokeWidth/2, getHeight()-strokeWidth/2), radius, radius, mPaint); 296 | } 297 | super.draw(canvas); 298 | } 299 | 300 | public int dip2px(float dpValue) { 301 | final float scale = getResources().getDisplayMetrics().density; 302 | return (int) (dpValue * scale + 0.5f); 303 | } 304 | 305 | } 306 | -------------------------------------------------------------------------------- /tagview/src/main/res/layout/tag_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 22 | 23 | -------------------------------------------------------------------------------- /tagview/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /tagview/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | TAGView 3 | 4 | -------------------------------------------------------------------------------- /tagview/src/test/java/com/jude/tagview/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.jude.tagview; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } --------------------------------------------------------------------------------