├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── menu │ │ │ │ └── menu_app.xml │ │ │ ├── layout │ │ │ │ ├── activity_second.xml │ │ │ │ └── activity_main.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── william │ │ │ └── gradient │ │ │ ├── MainActivity.kt │ │ │ └── SecondActivity.kt │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── william │ │ │ └── gradient │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── william │ │ └── gradient │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro └── build.gradle ├── library ├── .gitignore ├── consumer-rules.pro ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── res │ │ │ └── values │ │ │ │ ├── colors.xml │ │ │ │ └── attrs.xml │ │ └── java │ │ │ └── com │ │ │ └── william │ │ │ └── gradient │ │ │ ├── AnimateDirection.kt │ │ │ ├── TranslateSpeed.kt │ │ │ └── GradientTextView.kt │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── william │ │ │ └── gradient │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── william │ │ └── gradient │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro └── build.gradle ├── image ├── resource.gif └── screenshot.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea ├── codeStyles │ ├── codeStyleConfig.xml │ └── Project.xml ├── markdown-navigator ├── misc.xml ├── jarRepositories.xml ├── markdown-navigator.xml └── markdown-navigator-enh.xml ├── settings.gradle ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── README.md ├── gradlew └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /library/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /image/resource.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeiLianYang/GradientTextView/HEAD/image/resource.gif -------------------------------------------------------------------------------- /image/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeiLianYang/GradientTextView/HEAD/image/screenshot.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeiLianYang/GradientTextView/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeiLianYang/GradientTextView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeiLianYang/GradientTextView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeiLianYang/GradientTextView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeiLianYang/GradientTextView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeiLianYang/GradientTextView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeiLianYang/GradientTextView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeiLianYang/GradientTextView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeiLianYang/GradientTextView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeiLianYang/GradientTextView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeiLianYang/GradientTextView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/markdown-navigator: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright WeiLianYang 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | include ':library' 18 | include ':app' 19 | rootProject.name = "GradientTextView" -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /library/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /library/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | #6200EE 20 | #03DAC5 21 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | #6200EE 20 | #3700B3 21 | #03DAC5 22 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright WeiLianYang 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | #Sun Jul 05 20:29:35 CST 2020 18 | distributionBase=GRADLE_USER_HOME 19 | distributionPath=wrapper/dists 20 | zipStoreBase=GRADLE_USER_HOME 21 | zipStorePath=wrapper/dists 22 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip 23 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | GradientTextView 19 | leftToRight: GradientTextView! 20 | topToBottom: GradientTextView! 21 | toggle animate 22 | -------------------------------------------------------------------------------- /library/src/main/java/com/william/gradient/AnimateDirection.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright WeiLianYang 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.william.gradient 18 | 19 | import androidx.annotation.IntDef 20 | 21 | 22 | /** 23 | * @author William 24 | * @date 2022/1/9 16:30 25 | * Class Comment: 26 | */ 27 | 28 | @IntDef(flag = false, value = [GradientTextView.leftToRight, GradientTextView.topToBottom]) 29 | annotation class AnimateDirection 30 | -------------------------------------------------------------------------------- /library/src/main/java/com/william/gradient/TranslateSpeed.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright WeiLianYang 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.william.gradient 18 | 19 | import androidx.annotation.IntDef 20 | 21 | 22 | /** 23 | * @author William 24 | * @date 2022/1/9 16:30 25 | * Class Comment: 26 | */ 27 | 28 | @IntDef(flag = false, value = [GradientTextView.slow, GradientTextView.normal, GradientTextView.fast]) 29 | annotation class TranslateSpeed 30 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/test/java/com/william/gradient/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright WeiLianYang 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.william.gradient 18 | 19 | import org.junit.Test 20 | 21 | import org.junit.Assert.* 22 | 23 | /** 24 | * Example local unit test, which will execute on the development machine (host). 25 | * 26 | * See [testing documentation](http://d.android.com/tools/testing). 27 | */ 28 | class ExampleUnitTest { 29 | @Test 30 | fun addition_isCorrect() { 31 | assertEquals(4, 2 + 2) 32 | } 33 | } -------------------------------------------------------------------------------- /library/src/test/java/com/william/gradient/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright WeiLianYang 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.william.gradient 18 | 19 | import org.junit.Test 20 | 21 | import org.junit.Assert.* 22 | 23 | /** 24 | * Example local unit test, which will execute on the development machine (host). 25 | * 26 | * See [testing documentation](http://d.android.com/tools/testing). 27 | */ 28 | class ExampleUnitTest { 29 | @Test 30 | fun addition_isCorrect() { 31 | assertEquals(4, 2 + 2) 32 | } 33 | } -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_app.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | 26 | 27 | -------------------------------------------------------------------------------- /library/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/william/gradient/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright WeiLianYang 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.william.gradient 18 | 19 | import androidx.test.platform.app.InstrumentationRegistry 20 | import androidx.test.ext.junit.runners.AndroidJUnit4 21 | 22 | import org.junit.Test 23 | import org.junit.runner.RunWith 24 | 25 | import org.junit.Assert.* 26 | 27 | /** 28 | * Instrumented test, which will execute on an Android device. 29 | * 30 | * See [testing documentation](http://d.android.com/tools/testing). 31 | */ 32 | @RunWith(AndroidJUnit4::class) 33 | class ExampleInstrumentedTest { 34 | @Test 35 | fun useAppContext() { 36 | // Context of the app under test. 37 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 38 | assertEquals("com.william.gradient", appContext.packageName) 39 | } 40 | } -------------------------------------------------------------------------------- /library/src/androidTest/java/com/william/gradient/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright WeiLianYang 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.william.gradient 18 | 19 | import androidx.test.platform.app.InstrumentationRegistry 20 | import androidx.test.ext.junit.runners.AndroidJUnit4 21 | 22 | import org.junit.Test 23 | import org.junit.runner.RunWith 24 | 25 | import org.junit.Assert.* 26 | 27 | /** 28 | * Instrumented test, which will execute on an Android device. 29 | * 30 | * See [testing documentation](http://d.android.com/tools/testing). 31 | */ 32 | @RunWith(AndroidJUnit4::class) 33 | class ExampleInstrumentedTest { 34 | @Test 35 | fun useAppContext() { 36 | // Context of the app under test. 37 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 38 | assertEquals("com.william.library.test", appContext.packageName) 39 | } 40 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_second.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 24 | 25 | 33 | 34 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | 29 | 30 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 20 | 21 | 28 | 29 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.aar 4 | *.ap_ 5 | *.aab 6 | 7 | # Files for the ART/Dalvik VM 8 | *.dex 9 | 10 | # Java class files 11 | *.class 12 | 13 | # Generated files 14 | bin/ 15 | gen/ 16 | out/ 17 | # Uncomment the following line in case you need and you don't have the release build type files in your app 18 | # release/ 19 | 20 | # Gradle files 21 | .gradle/ 22 | build/ 23 | 24 | # Local configuration file (sdk path, etc) 25 | local.properties 26 | 27 | # Proguard folder generated by Eclipse 28 | proguard/ 29 | 30 | # Log Files 31 | *.log 32 | 33 | # Android Studio Navigation editor temp files 34 | .navigation/ 35 | 36 | # Android Studio captures folder 37 | captures/ 38 | 39 | # IntelliJ 40 | *.iml 41 | .idea/ 42 | .idea/workspace.xml 43 | .idea/tasks.xml 44 | .idea/gradle.xml 45 | .idea/assetWizardSettings.xml 46 | .idea/dictionaries 47 | .idea/libraries 48 | # Android Studio 3 in .gitignore file. 49 | .idea/caches 50 | .idea/modules.xml 51 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you 52 | .idea/navEditor.xml 53 | 54 | # Keystore files 55 | # Uncomment the following lines if you do not want to check your keystore files in. 56 | #*.jks 57 | #*.keystore 58 | 59 | # External native build folder generated in Android Studio 2.2 and later 60 | .externalNativeBuild 61 | .cxx/ 62 | 63 | # Google Services (e.g. APIs or Firebase) 64 | # google-services.json 65 | 66 | # Freeline 67 | freeline.py 68 | freeline/ 69 | freeline_project_description.json 70 | 71 | # fastlane 72 | fastlane/report.xml 73 | fastlane/Preview.html 74 | fastlane/screenshots 75 | fastlane/test_output 76 | fastlane/readme.md 77 | 78 | # Version control 79 | vcs.xml 80 | 81 | # lint 82 | lint/intermediates/ 83 | lint/generated/ 84 | lint/outputs/ 85 | lint/tmp/ 86 | # lint/reports/ 87 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright WeiLianYang 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | plugins { 18 | id 'com.android.application' 19 | id 'kotlin-android' 20 | } 21 | 22 | android { 23 | compileSdkVersion 32 24 | 25 | defaultConfig { 26 | applicationId "com.william.gradient" 27 | minSdkVersion 23 28 | targetSdkVersion 32 29 | versionCode 1 30 | versionName "1.0" 31 | 32 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 33 | } 34 | 35 | buildTypes { 36 | release { 37 | minifyEnabled false 38 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 39 | } 40 | } 41 | 42 | compileOptions { 43 | sourceCompatibility JavaVersion.VERSION_1_8 44 | targetCompatibility JavaVersion.VERSION_1_8 45 | } 46 | 47 | kotlinOptions { 48 | jvmTarget = "1.8" 49 | } 50 | 51 | buildFeatures { 52 | viewBinding true 53 | } 54 | } 55 | 56 | dependencies { 57 | implementation fileTree(dir: "libs", include: ["*.jar"]) 58 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 59 | implementation 'androidx.core:core-ktx:1.6.0' 60 | implementation 'androidx.appcompat:appcompat:1.3.1' 61 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 62 | testImplementation 'junit:junit:4.13.2' 63 | androidTestImplementation 'androidx.test.ext:junit:1.1.2' 64 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 65 | 66 | // implementation project(path: ':library') 67 | implementation 'io.github.weilianyang:gradienttext:1.0.3' 68 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright WeiLianYang 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | # Project-wide Gradle settings. 18 | # IDE (e.g. Android Studio) users: 19 | # Gradle settings configured through the IDE *will override* 20 | # any settings specified in this file. 21 | # For more details on how to configure your build environment visit 22 | # http://www.gradle.org/docs/current/userguide/build_environment.html 23 | # Specifies the JVM arguments used for the daemon process. 24 | # The setting is particularly useful for tweaking memory settings. 25 | org.gradle.jvmargs=-Xmx2048m 26 | # When configured, Gradle will run in incubating parallel mode. 27 | # This option should only be used with decoupled projects. More details, visit 28 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 29 | # org.gradle.parallel=true 30 | # AndroidX package structure to make it clearer which packages are bundled with the 31 | # Android operating system, and which are packaged with your app"s APK 32 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 33 | android.useAndroidX=true 34 | # Automatically convert third-party libraries to use AndroidX 35 | android.enableJetifier=true 36 | # Kotlin code style for this project: "official" or "obsolete": 37 | kotlin.code.style=official 38 | # 39 | # 发布配置 40 | publishedGroupId=io.github.weilianyang 41 | siteUrl=https://github.com/WeiLianYang/GradientTextView 42 | gitUrl=https://github.com/WeiLianYang/GradientTextView.git 43 | # developer 44 | developerId=WeiLianYang 45 | developerName=WeiLian 46 | developerEmail=williamyangc@163.com 47 | # license 48 | licenseName=The Apache License, Version 2.0 49 | licenseUrl=http://www.apache.org/licenses/LICENSE-2.0.txt 50 | allLicenses=["Apache-2.0"] -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright WeiLianYang 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | plugins { 18 | id 'com.android.library' 19 | id 'kotlin-android' 20 | } 21 | 22 | android { 23 | compileSdkVersion 32 24 | 25 | defaultConfig { 26 | minSdkVersion 21 27 | targetSdkVersion 32 28 | versionCode 4 29 | versionName "1.0.3" 30 | 31 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 32 | consumerProguardFiles "consumer-rules.pro" 33 | } 34 | 35 | buildTypes { 36 | release { 37 | minifyEnabled false 38 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 39 | } 40 | } 41 | 42 | compileOptions { 43 | sourceCompatibility JavaVersion.VERSION_1_8 44 | targetCompatibility JavaVersion.VERSION_1_8 45 | } 46 | 47 | kotlinOptions { 48 | jvmTarget = "1.8" 49 | } 50 | 51 | } 52 | 53 | dependencies { 54 | implementation fileTree(dir: "libs", include: ["*.jar"]) 55 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 56 | implementation 'androidx.core:core-ktx:1.6.0' 57 | implementation 'androidx.appcompat:appcompat:1.3.1' 58 | 59 | testImplementation 'junit:junit:4.13.2' 60 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 61 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 62 | 63 | } 64 | 65 | ext { 66 | artifactId = 'gradienttext' 67 | libraryName = 'GradientTextView' 68 | libraryDescription = 'Used to set the font gradient color, gradient direction, and animation effect of the TexView.' 69 | } 70 | 71 | apply from: 'https://raw.github.com/WeiLianYang/gradle-publish/master/publish.gradle' 72 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 23 | 24 | 25 | 31 | 34 | 37 | 38 | 39 | 40 | 46 | -------------------------------------------------------------------------------- /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 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 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 Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /app/src/main/java/com/william/gradient/MainActivity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright WeiLianYang 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.william.gradient 18 | 19 | import android.content.Intent 20 | import android.os.Bundle 21 | import android.view.Menu 22 | import android.view.MenuItem 23 | import androidx.appcompat.app.AppCompatActivity 24 | import com.william.gradient.databinding.ActivityMainBinding 25 | 26 | /** 27 | * @author William 28 | * @date 2020/7/5 22:04 29 | * Class Comment: 30 | */ 31 | class MainActivity : AppCompatActivity() { 32 | 33 | private lateinit var binding: ActivityMainBinding 34 | 35 | override fun onCreate(savedInstanceState: Bundle?) { 36 | super.onCreate(savedInstanceState) 37 | 38 | binding = ActivityMainBinding.inflate(layoutInflater) 39 | setContentView(binding.root) 40 | 41 | binding.btnSecond.setOnClickListener { 42 | startActivity(Intent(this, SecondActivity::class.java)) 43 | } 44 | } 45 | 46 | override fun onCreateOptionsMenu(menu: Menu?): Boolean { 47 | menuInflater.inflate(R.menu.menu_app, menu) 48 | return true 49 | } 50 | 51 | override fun onOptionsItemSelected(item: MenuItem): Boolean { 52 | val id: Int = item.itemId 53 | if (id == R.id.action_translate) { 54 | binding.apply { 55 | gradientTextView1.apply { 56 | translateAnimate = !translateAnimate 57 | invalidate() 58 | } 59 | gradientTextView2.apply { 60 | translateAnimate = !translateAnimate 61 | invalidate() 62 | } 63 | gradientTextView3.apply { 64 | translateAnimate = !translateAnimate 65 | invalidate() 66 | } 67 | 68 | gradientTextView5.apply { 69 | translateAnimate = !translateAnimate 70 | invalidate() 71 | } 72 | } 73 | return true 74 | } 75 | return super.onOptionsItemSelected(item) 76 | } 77 | 78 | override fun onPrepareOptionsMenu(menu: Menu?): Boolean { 79 | val show = super.onPrepareOptionsMenu(menu) 80 | return if (!show) show else true 81 | } 82 | } -------------------------------------------------------------------------------- /.idea/markdown-navigator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 29 | 30 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GradientTextView 2 | 3 | 4 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.weilianyang/gradienttext/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.weilianyang/gradienttext) [![API](https://img.shields.io/badge/API-21%2B-orange.svg?style=flat)](https://android-arsenal.com/api?level=21) [![License](https://img.shields.io/badge/License%20-Apache%202-337ab7.svg)](https://github.com/WeiLianYang/GradientTextView/blob/master/LICENSE) 5 | 6 | 7 | ### 🔥🔥🔥用于设置TexView的字体 *渐变颜色*、*渐变方向* 和 *动画效果* 8 | 9 | ### 添加依赖 10 | 11 | ```groovy 12 | buildscript { 13 | repositories { 14 | mavenCentral() 15 | } 16 | } 17 | 18 | implementation 'io.github.weilianyang:gradienttext:1.0.3' 19 | ``` 20 | 21 | ### 效果预览: 22 | 23 | ![效果动图](https://img-blog.csdnimg.cn/20200711210227216.gif) ![效果静态图](https://img-blog.csdnimg.cn/20200711210218233.png) 24 | 25 | ### 一、控件样式 26 | 27 | ```xml 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | ``` 43 | 44 | ### 二、属性介绍 45 | 46 | | 属性 | 可选值 | 作用 | 47 | |:--------------------|:-----------------------------------------|:-------------------------------| 48 | | gradient_startColor | 值在color.xml中定义 | 渐变颜色的起始值(默认值:#6200EE) | 49 | | gradient_endColor | 值在color.xml中定义 | 渐变颜色的结束值(默认值:#03DAC5) | 50 | | gradient_direction | leftToRight:从左向右,topToBottom:从上向下 | 渐变颜色的方向(默认值:leftToRight) | 51 | | gradient_animate | true or false | 渐变颜色的动画开关(默认值:false) | 52 | | gradient_speed | slow、normal、fast | 渐变颜色的动画速度(默认值:normal) | 53 | 54 | ### 三、布局声明 55 | 56 | ```xml 57 | 67 | ``` 68 | 69 | ### 四、代码创建 70 | 71 | ```kotlin 72 | GradientTextView(this).apply { 73 | layoutParams = 74 | ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, 100) 75 | .apply { 76 | topToTop = ConstraintLayout.LayoutParams.PARENT_ID 77 | topMargin = 100 78 | leftMargin = 100 79 | } 80 | this.text = "text" 81 | this.textSize = 18f 82 | 83 | this.direction = GradientTextView.leftToRight 84 | this.translateSpeed = GradientTextView.normal 85 | this.translateAnimate = true 86 | 87 | setColor( 88 | ContextCompat.getColor(this@SecondActivity, R.color.color_03DAC5), 89 | ContextCompat.getColor(this@SecondActivity, R.color.color_6200EE) 90 | ) 91 | } 92 | ``` 93 | 94 | ### 五、控制动画开关 95 | 96 | ```kotlin 97 | gradientTextView.apply { 98 | translateAnimate = !translateAnimate 99 | invalidate() 100 | } 101 | ``` 102 | 103 | -------------------------------------------------------------------------------- /app/src/main/java/com/william/gradient/SecondActivity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright WeiLianYang 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.william.gradient 18 | 19 | import android.os.Bundle 20 | import androidx.appcompat.app.AppCompatActivity 21 | import androidx.constraintlayout.widget.ConstraintLayout 22 | import androidx.core.content.ContextCompat 23 | import com.william.gradient.databinding.ActivitySecondBinding 24 | 25 | /** 26 | * @author William 27 | * @date 2022/1/9 15:05 28 | * Class Comment: 29 | */ 30 | class SecondActivity : AppCompatActivity() { 31 | 32 | private lateinit var binding: ActivitySecondBinding 33 | 34 | override fun onCreate(savedInstanceState: Bundle?) { 35 | super.onCreate(savedInstanceState) 36 | 37 | binding = ActivitySecondBinding.inflate(layoutInflater) 38 | setContentView(binding.root) 39 | 40 | val silentTextView1 = createGradientTextView( 41 | "Gradient TextView topToBottom", 42 | GradientTextView.topToBottom, 43 | animate = false 44 | ) 45 | binding.root.addView(silentTextView1) 46 | 47 | val silentTextView2 = createGradientTextView( 48 | "Gradient TextView leftToRight", 49 | GradientTextView.leftToRight, 50 | animate = false 51 | ) 52 | binding.root.addView(silentTextView2) 53 | 54 | val slowTextView = createGradientTextView( 55 | "Gradient TextView Speed: Slow", 56 | GradientTextView.leftToRight, 57 | GradientTextView.slow 58 | ) 59 | binding.root.addView(slowTextView) 60 | 61 | val normalTextView = createGradientTextView( 62 | "Gradient TextView Speed: Normal", 63 | GradientTextView.leftToRight, 64 | GradientTextView.normal 65 | ) 66 | binding.root.addView(normalTextView) 67 | 68 | val fastTextView = createGradientTextView( 69 | "Gradient TextView Speed: Fast", 70 | GradientTextView.leftToRight, 71 | GradientTextView.fast 72 | ) 73 | binding.root.addView(fastTextView) 74 | 75 | } 76 | 77 | private var topY = 150 78 | 79 | private fun createGradientTextView( 80 | text: String, 81 | @AnimateDirection direction: Int, 82 | @TranslateSpeed speed: Int = 0, 83 | animate: Boolean = true 84 | ): GradientTextView { 85 | 86 | topY += 150 87 | 88 | return GradientTextView(this).apply { 89 | layoutParams = 90 | ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, 100) 91 | .apply { 92 | topToTop = ConstraintLayout.LayoutParams.PARENT_ID 93 | 94 | topMargin = topY 95 | leftMargin = 100 96 | } 97 | this.text = text 98 | this.textSize = 18f 99 | 100 | this.direction = direction 101 | this.translateSpeed = speed 102 | this.translateAnimate = animate 103 | 104 | setColor( 105 | ContextCompat.getColor(this@SecondActivity, R.color.color_03DAC5), 106 | ContextCompat.getColor(this@SecondActivity, R.color.color_6200EE) 107 | ) 108 | } 109 | } 110 | } -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | xmlns:android 17 | 18 | ^$ 19 | 20 | 21 | 22 |
23 |
24 | 25 | 26 | 27 | xmlns:.* 28 | 29 | ^$ 30 | 31 | 32 | BY_NAME 33 | 34 |
35 |
36 | 37 | 38 | 39 | .*:id 40 | 41 | http://schemas.android.com/apk/res/android 42 | 43 | 44 | 45 |
46 |
47 | 48 | 49 | 50 | .*:name 51 | 52 | http://schemas.android.com/apk/res/android 53 | 54 | 55 | 56 |
57 |
58 | 59 | 60 | 61 | name 62 | 63 | ^$ 64 | 65 | 66 | 67 |
68 |
69 | 70 | 71 | 72 | style 73 | 74 | ^$ 75 | 76 | 77 | 78 |
79 |
80 | 81 | 82 | 83 | .* 84 | 85 | ^$ 86 | 87 | 88 | BY_NAME 89 | 90 |
91 |
92 | 93 | 94 | 95 | .* 96 | 97 | http://schemas.android.com/apk/res/android 98 | 99 | 100 | ANDROID_ATTRIBUTE_ORDER 101 | 102 |
103 |
104 | 105 | 106 | 107 | .* 108 | 109 | .* 110 | 111 | 112 | BY_NAME 113 | 114 |
115 |
116 |
117 |
118 | 119 | 121 |
122 |
-------------------------------------------------------------------------------- /.idea/markdown-navigator-enh.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 24 | 25 |