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

Android中的HTextView庫(kù)實(shí)現(xiàn)TextView動(dòng)畫效果

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

Android開發(fā)中,我們可能會(huì)遇到實(shí)現(xiàn)某個(gè)TextView實(shí)現(xiàn)動(dòng)畫效果。關(guān)于這種需求,我給小伙們推薦推薦HTextView開源庫(kù),希望能小伙伴們提高開發(fā)效率。HTextView是一個(gè)用來(lái)給TextView里的文字做各種轉(zhuǎn)換動(dòng)畫的開源庫(kù)。

HTextView前言

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

HTextView的簡(jiǎn)單使用方法

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

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

HTextView引入

寫博客的時(shí)候,最新的版本是0.1.6。小伙伴們使用的時(shí)候,可以看看有沒(méi)有更新版本。引入基礎(chǔ)模塊:

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;

總結(jié)

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

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

相關(guān)文章

最新評(píng)論