欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android中的HTextView庫實現(xiàn)TextView動畫效果

 更新時間:2023年12月02日 10:18:39   作者:阿博聊編程  
HTextView是一個用來給TextView里的文字做各種轉換動畫的開源庫,不僅提供了多種動畫選擇,而且還有重復字符的位移動畫,雖然并沒有多么復雜,但是它使用的這些典型的設計模式以及各種動畫的實現(xiàn)確實可以從中讓我們學到不少知識

Android開發(fā)中,我們可能會遇到實現(xiàn)某個TextView實現(xiàn)動畫效果。關于這種需求,我給小伙們推薦推薦HTextView開源庫,希望能小伙伴們提高開發(fā)效率。HTextView是一個用來給TextView里的文字做各種轉換動畫的開源庫。

HTextView前言

第一次看到這個庫的時候就被這些動畫吸引了,不僅提供了多種動畫選擇,而且還有重復字符的位移動畫,的確別出心裁,雖然實現(xiàn)起來并不是多么復雜,但是從1700+的star數(shù)上還是可以看出它的受歡迎程度,所以今天我們就來分析看看它到底是如何實現(xiàn)的.有哪些值得我們借鑒的地方,又有哪些不完善的地方。

HTextView的簡單使用方法

HTextView的使用方法還是比較簡單的,只需要調(diào)用hTextView.setAnimateType();來設定一種動畫的類型,再調(diào)用hTextView.animateText();將字符串傳入就可以執(zhí)行切換動畫了,此外還提供了hTextView.reset();方法來重置動畫,具體代碼如下:

hTextView.setAnimateType(HTextViewType.SCALE);
hTextView.animateText(sentences[mCounter]);

HTextView引入

寫博客的時候,最新的版本是0.1.6。小伙伴們使用的時候,可以看看有沒有更新版本。引入基礎模塊:

implementation "com.hanks:htextview-base:0.1.6" 

下面的可以按需引入:

implementation "com.hanks:htextview-fade:0.1.6"       
implementation "com.hanks:htextview-line:0.1.6"       
implementation "com.hanks:htextview-rainbow:0.1.6"     
implementation "com.hanks:htextview-typer:0.1.6"     
implementation "com.hanks:htextview-scale:0.1.6"       
implementation "com.hanks:htextview-evaporate:0.1.6"   
implementation "com.hanks:htextview-fall:0.1.6" 

line使用以及效果

<com.hanks.htextview.line.LineTextView
    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使用以及效果

<com.hanks.htextview.fade.FadeTextView
    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"/>

typer使用以及效果

<com.hanks.htextview.typer.TyperTextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="this is init sentence."
    app:charIncrease="3"
    app:typerSpeed="80"/>

rainbow使用以及效果

<com.hanks.htextview.rainbow.RainbowTextView
    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"/>

scale使用以及效果

<com.hanks.htextview.scale.ScaleTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="this is init sentence"
    android:textSize="16sp"/>

evaporate使用以及效果

<com.hanks.htextview.evaporate.EvaporateTextView
    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使用以及效果

&lt;com.hanks.htextview.fall.FallTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="20dp"
    android:text="this is init sentence"
    android:textSize="16sp"/&gt;

總結

至此,我們就算是徹底了解了HTextView,雖然并沒有多么復雜,但是它使用的這些典型的設計模式以及各種動畫的實現(xiàn)確實可以從中讓我們學到不少知識。尤其是各種動畫的具體實現(xiàn),能為我們自己在做相關動畫時提供不少思路!感覺給TextView加動畫效果還是很棒的,有機會的話可以在項目中使用到。

到此這篇關于Android中的HTextView庫實現(xiàn)TextView動畫效果的文章就介紹到這了,更多相關Android中的HTextView庫實現(xiàn)動畫內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

最新評論