您好,登錄后才能下訂單哦!
要實(shí)現(xiàn)TextView文本動(dòng)態(tài)變化的背景,可以通過(guò)創(chuàng)建一個(gè)帶有動(dòng)畫(huà)效果的Drawable資源文件,并將其設(shè)置為T(mén)extView的背景。以下是具體步驟:
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item
android:drawable="@drawable/bg_color1"
android:duration="500" />
<item
android:drawable="@drawable/bg_color2"
android:duration="500" />
<item
android:drawable="@drawable/bg_color3"
android:duration="500" />
</animation-list>
bg_color1.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FF0000" />
</shape>
bg_color2.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#00FF00" />
</shape>
bg_color3.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#0000FF" />
</shape>
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dynamic Background"
android:background="@drawable/bg_animation" />
TextView textView = findViewById(R.id.textView);
AnimationDrawable animationDrawable = (AnimationDrawable) textView.getBackground();
animationDrawable.start();
通過(guò)以上步驟,就可以實(shí)現(xiàn)TextView文本動(dòng)態(tài)變化的背景效果。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。