existAndroid
During development, we may encounter implementation of a certainTextView
Achieve animation effects. Regarding this kind of demand, I recommend it to the guysHTextView
Open source library, I hope that friends can improve development efficiency. HTextView is an open source library used to make various conversion animations for text in TextView.
HTextView Preface
When I first saw this library, I was attracted by these animations. Not only did it provide a variety of animation options, but it also had bit-moving paintings of repeated characters. It is indeed unique. Although it is not very complicated to implement, it can still be seen from the number of stars of 1700+, so today we will analyze how it is implemented. What are the points worth learning from and what are the incompleteness.
Simple way to use HTextView
The usage method of HTextView is relatively simple, you only need to call it();
Set an animation type and call it();
Passing the string in can execute the switching animation, in addition, it also provides();
The method is used to reset the animation, the specific code is as follows:
(); (sentences[mCounter]);
HTextView introduction
When writing a blog, the latest version is0.1.6
. When you use it, you can check if there is an updated version. Introducing basic modules:
implementation ":htextview-base:0.1.6"
The following can be introduced as needed:
implementation ":htextview-fade:0.1.6" implementation ":htextview-line:0.1.6" implementation ":htextview-rainbow:0.1.6" implementation ":htextview-typer:0.1.6" implementation ":htextview-scale:0.1.6" implementation ":htextview-evaporate:0.1.6" implementation ":htextview-fall:0.1.6"
Line usage and effects
< android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:paddingRight="10dp" android:text="This is LineTextView\nToday is Monday" android:textSize="16sp" app:animationDuration="3000" app:lineColor="#1367bc" app:lineWidth="4dp"/>
Fade usage and effects
< android:layout_width="240dp" android:layout_height="150dp" android:gravity="left" android:letterSpacing="0.08" android:lineSpacingMultiplier="1.3" android:text="This is FadeTextView" android:textColor="#fff" android:textSize="20sp" app:animationDuration="1500"/>
Type usage and effects
< android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="this is init sentence." app:charIncrease="3" app:typerSpeed="80"/>
Rainbow usage and effects
< android:layout_width="120dp" android:layout_height="wrap_content" android:gravity="right" android:text="this is init sentence" android:textSize="20sp" app:colorSpace="150dp" app:colorSpeed="4dp"/>
Use and effects of scale
< android:layout_width="match_parent" android:layout_height="wrap_content" android:text="this is init sentence" android:textSize="16sp"/>
Use and effects of evaporate
< android:layout_width="match_parent" android:layout_height="100dp" android:gravity="center" android:paddingTop="8dp" android:text="this is init sentence" android:textSize="20sp"/>
Fall usage and effects
< android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingBottom="20dp" android:text="this is init sentence" android:textSize="16sp"/>
Summarize
At this point, even if we have a thorough understanding of HTextView, although it is not very complicated, the typical design patterns it uses and the implementation of various animations can indeed allow us to learn a lot from it. Especially the specific implementation of various animations can provide us with a lot of ideas when making related animations!TextView
The animation effect is still great, and you can use it in the project if you have the chance.
This is the article about the implementation of TextView animation effect of the HTextView library in Android. For more related content on the implementation of the HTextView library in Android, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!