├── .gitignore ├── LICENSE ├── README.md ├── animatedtext ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── omega │ │ └── animatedtext │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── omega │ │ │ └── animatedtext │ │ │ └── AnimatedTextView.java │ └── res │ │ └── values │ │ ├── attrs.xml │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── omega │ └── animatedtext │ └── ExampleUnitTest.java ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── omega │ │ └── omegaanimatedtext │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── omega │ │ │ └── omegaanimatedtext │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── 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 │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── omega │ └── omegaanimatedtext │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── images └── AnimatedTextPreview.gif └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # IntelliJ 36 | *.iml 37 | .idea/ 38 | 39 | # Keystore files 40 | # Uncomment the following line if you do not want to check your keystore files in. 41 | #*.jks 42 | 43 | # External native build folder generated in Android Studio 2.2 and later 44 | .externalNativeBuild 45 | 46 | # Google Services (e.g. APIs or Firebase) 47 | google-services.json 48 | 49 | # Freeline 50 | freeline.py 51 | freeline/ 52 | freeline_project_description.json 53 | 54 | # fastlane 55 | fastlane/report.xml 56 | fastlane/Preview.html 57 | fastlane/screenshots 58 | fastlane/test_output 59 | fastlane/readme.md 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Omega-R 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![](https://jitpack.io/v/Omega-R/OmegaAnimatedText.svg)](https://jitpack.io/#Omega-R/OmegaAnimatedText) 2 | [![GitHub license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://opensource.org/licenses/MIT) 3 | # AnimatedText 4 | Android lib to animate bold and italic transformations in TextView. 5 | 6 |

7 | 8 |

9 | 10 | # Installation 11 | To get a Git project into your build: 12 | 13 | **Step 1.** Add the JitPack repository to your build file 14 | ``` 15 | allprojects { 16 | repositories { 17 | ... 18 | maven { url 'https://jitpack.io' } 19 | } 20 | } 21 | ``` 22 | **Step 2.** Add the dependency 23 | ``` 24 | dependencies { 25 | implementation 'com.github.Omega-R:OmegaAnimatedText:2.0.0' 26 | } 27 | ``` 28 | 29 | For Support library the latest version is '1.0.0' 30 | 31 | # Usage 32 | Start animation: 33 | ``` Java 34 | animatedTextView.createStrokeAnimator(0.05f).start(); 35 | animatedTextView.createItalicAnimator(0.4f) 36 | .setDuration(1000) 37 | .start(); 38 | ``` 39 | 40 | # Note 41 | createStrokeAnimator(...) takes float percentage of textSize as first parameter. 42 | 43 | createItalicAnimator(...) takes float percentage of skew angle (from 0.0f for 0° to 1.0f for 90°) as first parameter. 44 | 45 | Both methods returns android.animation.Animator instance so you can make animations more complicated. 46 | 47 | # License 48 | ``` 49 | The MIT License 50 | 51 | Copyright 2020 Omega-R 52 | 53 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 54 | associated documentation files (the "Software"), to deal in the Software without restriction, 55 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 56 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 57 | furnished to do so, subject to the following conditions: 58 | 59 | The above copyright notice and this permission notice shall be included in all copies or substantial 60 | portions of the Software. 61 | 62 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 63 | LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 64 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 65 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 66 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 67 | ``` 68 | -------------------------------------------------------------------------------- /animatedtext/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /animatedtext/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 29 5 | defaultConfig { 6 | minSdkVersion 15 7 | targetSdkVersion 29 8 | versionCode 1 9 | versionName "2.0.0" 10 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 11 | } 12 | buildTypes { 13 | release { 14 | minifyEnabled false 15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 16 | } 17 | } 18 | } 19 | 20 | dependencies { 21 | implementation fileTree(dir: 'libs', include: ['*.jar']) 22 | implementation 'androidx.appcompat:appcompat:1.1.0' 23 | testImplementation "junit:junit:4.12" 24 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 25 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 26 | } 27 | -------------------------------------------------------------------------------- /animatedtext/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 22 | -------------------------------------------------------------------------------- /animatedtext/src/androidTest/java/com/omega/animatedtext/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.omega.animatedtext; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.omega.animatedtext.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /animatedtext/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /animatedtext/src/main/java/com/omega/animatedtext/AnimatedTextView.java: -------------------------------------------------------------------------------- 1 | package com.omega.animatedtext; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.content.Context; 6 | import android.graphics.Canvas; 7 | import android.graphics.Paint; 8 | import android.util.AttributeSet; 9 | 10 | import androidx.appcompat.widget.AppCompatTextView; 11 | 12 | public class AnimatedTextView extends AppCompatTextView { 13 | 14 | private float mStrokeScale = 0.0f; 15 | private float mItalicSkew = 0.0f; 16 | private float mOffset = 0.0f; 17 | private ValueAnimator mStrokeAnimator; 18 | private ValueAnimator mSkewAnimator; 19 | 20 | public AnimatedTextView(Context context) { 21 | this(context, null); 22 | } 23 | 24 | public AnimatedTextView(Context context, AttributeSet attributeSet) { 25 | this(context, attributeSet, 0); 26 | } 27 | 28 | public AnimatedTextView(Context context, AttributeSet attributeSet, int defStyleAttributes) { 29 | super(context, attributeSet, defStyleAttributes); 30 | 31 | } 32 | 33 | public float getStrokeScale() { 34 | return mStrokeScale; 35 | } 36 | 37 | public void setStrokeScale(float strokeScale) { 38 | mStrokeScale = strokeScale; 39 | invalidate(); 40 | } 41 | 42 | public float getItalicSkew() { 43 | return mItalicSkew; 44 | } 45 | 46 | public void setItalicSkew(float italicSkew) { 47 | mItalicSkew = italicSkew; 48 | invalidate(); 49 | } 50 | 51 | @Override 52 | protected void onDraw(Canvas canvas) { 53 | canvas.skew(-mItalicSkew, 0.0f); 54 | canvas.translate(mOffset, 0.0f); 55 | Paint p = getPaint(); 56 | p.setStyle(Paint.Style.FILL_AND_STROKE); 57 | p.setStrokeWidth(mStrokeScale * getTextSize()); 58 | super.onDraw(canvas); 59 | } 60 | 61 | public Animator createStrokeAnimator(float targetStrokeScale) { 62 | return createStrokeAnimator(targetStrokeScale, true); 63 | } 64 | 65 | public Animator createStrokeAnimator(float targetStrokeScale, boolean shouldEndExisting) { 66 | if (shouldEndExisting) endAnimation(mStrokeAnimator); 67 | mStrokeAnimator = ValueAnimator.ofFloat(mStrokeScale, targetStrokeScale); 68 | mStrokeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 69 | @Override 70 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 71 | mStrokeScale = (float)valueAnimator.getAnimatedValue(); 72 | if (mStrokeScale > 0) invalidate(); 73 | } 74 | }); 75 | return mStrokeAnimator; 76 | } 77 | 78 | public Animator createItalicAnimator(float targetSkew) { 79 | return createItalicAnimator(targetSkew, true); 80 | } 81 | 82 | public Animator createItalicAnimator(float targetSkew, boolean shouldEndExisting) { 83 | if (shouldEndExisting) endAnimation(mSkewAnimator); 84 | mSkewAnimator = ValueAnimator.ofFloat(mItalicSkew, targetSkew); 85 | mSkewAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 86 | @Override 87 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 88 | mItalicSkew = (float)valueAnimator.getAnimatedValue(); 89 | calcOffset(); 90 | if (mItalicSkew > 0) invalidate(); 91 | } 92 | }); 93 | return mSkewAnimator; 94 | } 95 | 96 | 97 | private void calcOffset() { 98 | mOffset = getTextSize() * (float)Math.tan(mItalicSkew); 99 | } 100 | 101 | private void endAnimation(ValueAnimator animator) { 102 | if (animator != null && animator.isRunning()) { 103 | animator.removeAllUpdateListeners(); 104 | animator.cancel(); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /animatedtext/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /animatedtext/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AnimatedText 3 | 4 | -------------------------------------------------------------------------------- /animatedtext/src/test/java/com/omega/animatedtext/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.omega.animatedtext; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 29 5 | defaultConfig { 6 | applicationId "com.omega.omegaanimatedtext" 7 | minSdkVersion 15 8 | targetSdkVersion 29 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(include: ['*.jar'], dir: 'libs') 23 | implementation 'androidx.appcompat:appcompat:1.1.0' 24 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 25 | testImplementation "junit:junit:4.12" 26 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 27 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 28 | implementation project(':animatedtext') 29 | } 30 | -------------------------------------------------------------------------------- /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 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/omega/omegaanimatedtext/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.omega.omegaanimatedtext; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.omega.omegaanimatedtext", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/omega/omegaanimatedtext/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.omega.omegaanimatedtext; 2 | 3 | import android.os.Bundle; 4 | import android.view.View; 5 | 6 | import androidx.appcompat.app.AppCompatActivity; 7 | 8 | import com.omega.animatedtext.AnimatedTextView; 9 | 10 | public class MainActivity extends AppCompatActivity implements View.OnClickListener { 11 | 12 | private AnimatedTextView mTextView; 13 | 14 | @Override 15 | public void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_main); 18 | findViewById(R.id.fwd_button).setOnClickListener(this); 19 | findViewById(R.id.fwd_italic_button).setOnClickListener(this); 20 | findViewById(R.id.back_button).setOnClickListener(this); 21 | findViewById(R.id.back_italic_button).setOnClickListener(this); 22 | mTextView = findViewById(R.id.strokeTextView); 23 | } 24 | 25 | @Override 26 | public void onClick(View view) { 27 | switch (view.getId()) { 28 | case (R.id.fwd_button): 29 | mTextView.createStrokeAnimator(0.05f).start(); 30 | break; 31 | case (R.id.fwd_italic_button): 32 | mTextView.createItalicAnimator(0.4f) 33 | .setDuration(1000) 34 | .start(); 35 | break; 36 | case (R.id.back_button): 37 | mTextView.createStrokeAnimator(0.0f).start(); 38 | break; 39 | case (R.id.back_italic_button): 40 | mTextView.createItalicAnimator(0.0f) 41 | .setDuration(1000) 42 | .start(); 43 | break; 44 | default: 45 | break; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 20 | 21 |