Android中的補(bǔ)間動(dòng)畫(tween)的簡(jiǎn)單使用-創(chuàng)新互聯(lián)

相對(duì)幀動(dòng)畫,補(bǔ)間動(dòng)畫(tween)可以這么理解:我們不必像幀動(dòng)畫一樣指定動(dòng)畫的每一幀,只需定義一個(gè)動(dòng)畫的開始和結(jié)束關(guān)鍵幀,而中間變化的幀由系統(tǒng)幫我們計(jì)算。

成都創(chuàng)新互聯(lián)公司主營(yíng)和順網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,app軟件開發(fā)公司,和順h5小程序定制開發(fā)搭建,和順網(wǎng)站營(yíng)銷推廣歡迎和順等地區(qū)企業(yè)咨詢

tween動(dòng)畫可以分為下面幾種:

AlphaAnimation(透明漸變動(dòng)畫):

示例:res/anim/alpha.xml

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="2000"  
    android:fillAfter="true"
    android:fromAlpha="0.0"
    android:repeatCount="1"
    android:repeatMode="reverse"
    android:toAlpha="1.0" >

</alpha>

屬性介紹:

duration:動(dòng)畫持續(xù)的時(shí)間

fromAlpha:漸變開始值,F(xiàn)loat 0.0完全透明 1.0完全不透明

toAlpha:漸變結(jié)束值

repeatCount: 動(dòng)畫重復(fù)次數(shù)

repeatMode:動(dòng)畫重復(fù)模式,["repeat"|"reverse"] repeat(透明-不透明 透明-不透明)

reverse(透明-不透明 不透明-透明)

開始動(dòng)畫:

Animation animation = AnimationUtils.loadAnimation(this, R.anim.alpha);
iv.startAnimation(animation);    //使用ImageView的startAnimation開始動(dòng)畫

ScaleAnimation(縮放動(dòng)畫):

res/anim/scale.xml

<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="2000"
    android:fillAfter="false"
    android:fromXScale="0.2"
    android:fromYScale="0.2"
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatCount="1"
    android:repeatMode="reverse"
    android:toXScale="2.0"
    android:toYScale="2.0" >

</scale>

主要屬性說明:

fromXScale,fromYScale: 動(dòng)畫開始時(shí)縮放比(x,y軸)

toXScale,toYscale: 動(dòng)畫結(jié)束時(shí)縮放比

pivotX,pivotY:縮放中心點(diǎn) (50%,50%)則為自身中心點(diǎn)(0,0)左上方

TranslateAnimation(位移動(dòng)畫):

res/anim/translate.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXDelta="-50%p"
    android:fromYDelta="0.0"
    android:toXDelta="50%p"
    android:toYDelta="0.0"
    android:repeatCount="1"
    android:repeatMode="reverse"
    android:duration="2000"
     >

</translate>

fromXDelta fromYDelta:開始位置坐標(biāo),可以是Float值和百分比 50%p以父容器為參考

toXDelta toYDelta: 結(jié)束位置坐標(biāo)

RotateAnimation(旋轉(zhuǎn)動(dòng)畫):

res/anim/rotate.xml

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0"
    android:toDegrees="360"
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatCount="1"
    android:repeatMode="reverse"
    android:duration="2000" >

</rotate>

屬性介紹:

fromDegrees:旋轉(zhuǎn)開始角度

toDegrees:旋轉(zhuǎn)結(jié)束角度,

pivotX pivotY:旋轉(zhuǎn)中心點(diǎn)

上面動(dòng)畫實(shí)現(xiàn)以自身中心點(diǎn)為基準(zhǔn)點(diǎn)旋轉(zhuǎn)360度

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

網(wǎng)站標(biāo)題:Android中的補(bǔ)間動(dòng)畫(tween)的簡(jiǎn)單使用-創(chuàng)新互聯(lián)
文章路徑:http://muchs.cn/article32/cdohpc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)網(wǎng)站營(yíng)銷、小程序開發(fā)、搜索引擎優(yōu)化、商城網(wǎng)站App設(shè)計(jì)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)