知識(shí)
不管是網(wǎng)站,軟件還是小程序,都要直接或間接能為您產(chǎn)生價(jià)值,我們?cè)谧非笃湟曈X(jué)表現(xiàn)的同時(shí),更側(cè)重于功能的便捷,營(yíng)銷的便利,運(yùn)營(yíng)的高效,讓網(wǎng)站成為營(yíng)銷工具,讓軟件能切實(shí)提升企業(yè)內(nèi)部管理水平和效率。優(yōu)秀的程序?yàn)楹笃谏?jí)提供便捷的支持!
android基本動(dòng)畫(huà),代碼構(gòu)建動(dòng)畫(huà)
發(fā)表時(shí)間:2020-10-19
發(fā)布人:葵宇科技
瀏覽次數(shù):44
應(yīng)用代碼構(gòu)建android根本動(dòng)畫(huà),根本動(dòng)畫(huà)有以下:
AlphaAnimation:漸變透明度動(dòng)畫(huà)
RotateAnimation:扭遷移轉(zhuǎn)變畫(huà)
ScaleAnimation:伸縮動(dòng)畫(huà)
TranslateAnimation:平移動(dòng)畫(huà)
可以定義出一些常用的動(dòng)畫(huà)效不雅,也可以自定義一些動(dòng)畫(huà),把參數(shù)預(yù)留出來(lái)。
可以定義一些組合動(dòng)畫(huà)效不雅,例如:大年夜里到外的效不雅。對(duì)于組合的動(dòng)畫(huà)效不雅,應(yīng)用根本的動(dòng)畫(huà)效不雅構(gòu)建起來(lái)。
應(yīng)用AnimationSet添加到此集合中,讓其瑯綾擎的動(dòng)畫(huà)一路起效不雅,可以看到意想不到的效不雅。
代碼對(duì)象類
/** * 應(yīng)用代碼設(shè)計(jì)的動(dòng)畫(huà) * */ public class AnimationCodeUtils { private static Animation anim; /** * 默認(rèn)的是: 1.透明度大年夜1.0~0, 2.動(dòng)畫(huà)時(shí)光3000毫秒 3.一向在動(dòng)畫(huà)停止?fàn)顩r * * @return 漸變透明度動(dòng)畫(huà) */ public static AlphaAnimation alphaAnimation1To0() { AlphaAnimation alpha = new AlphaAnimation(1.0f, 0.0f); alpha.setDuration(3000); return alpha; } /** * 默認(rèn)的是: 1.透明度大年夜0.0~1, 2.動(dòng)畫(huà)時(shí)光3000毫秒 3.一向在動(dòng)畫(huà)停止?fàn)顩r * * @return 漸變透明度動(dòng)畫(huà) */ public static AlphaAnimation alphaAnimation0To1() { AlphaAnimation alpha = new AlphaAnimation(0.0f, 1.0f); alpha.setDuration(3000); return alpha; } /** * @param fromAlpha * 開(kāi)端透明度(0~1.0) * @param toAlpha * 停止透明度(0~1.0) * @param durationMillis * 動(dòng)畫(huà)履行時(shí)光 * @param fillAfter * 是否逗留在動(dòng)畫(huà)停止?fàn)顩r * @return */ public static AlphaAnimation alphaAnimationCustom(float fromAlpha, float toAlpha, long durationMillis, boolean fillAfter) { AlphaAnimation alpha = new AlphaAnimation(fromAlpha, toAlpha); alpha.setDuration(durationMillis); alpha.setFillAfter(fillAfter); return alpha; } /** * 扭遷移轉(zhuǎn)變畫(huà),順時(shí)針360 默認(rèn):1.扭轉(zhuǎn)角度:0~360 2.相對(duì)于本身的中間腸位 3.扭轉(zhuǎn)時(shí)光為30004.一向留在動(dòng)畫(huà)停止?fàn)顩r * * @return */ public static RotateAnimation rotateAnimation0to360() { RotateAnimation rotate = new RotateAnimation(0f, 360f, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); rotate.setDuration(3000); rotate.setFillAfter(false); return rotate; } /** * 扭遷移轉(zhuǎn)變畫(huà),逆時(shí)針360 默認(rèn):1.扭轉(zhuǎn)角度:360-0 2.相對(duì)于本身的中間腸位 3.扭轉(zhuǎn)時(shí)光為30004.一向留在動(dòng)畫(huà)停止?fàn)顩r * * @return */ public static RotateAnimation rotateAnimation360to0() { RotateAnimation rotate = new RotateAnimation(360f, 0f, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); rotate.setDuration(3000); rotate.setFillAfter(false); return rotate; } /** * * 扭遷移轉(zhuǎn)變畫(huà),自定義 * * @return */ /** * @param fromDegrees * 開(kāi)端扭轉(zhuǎn)的角度 * @param toDegrees * 停止的角度 * @param pivotXType * X偏向相對(duì)地位類型 * @param pivotXValue * X偏向相對(duì)地位的值 * @param pivotYType * Y偏向相對(duì)地位類型 * @param pivotYValue * Y偏向相對(duì)地位的值 * @param durationMillis * 動(dòng)畫(huà)履行時(shí)光 * @param fillAfter * 是否逗留在動(dòng)畫(huà)停止時(shí)光 * @return */ public static RotateAnimation rotateAnimationCustom(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue, long durationMillis, boolean fillAfter) { RotateAnimation rotate = new RotateAnimation(fromDegrees, toDegrees, pivotXType, pivotXValue, pivotYType, pivotYValue); rotate.setDuration(durationMillis); rotate.setFillAfter(fillAfter); return rotate; } /** * 伸縮動(dòng)畫(huà) 默認(rèn):相對(duì)于本身,向左上角縮小,大年夜有到無(wú),動(dòng)畫(huà)時(shí)光3000,一向留在動(dòng)畫(huà)停止?fàn)顩r */ public static ScaleAnimation scaleAnimation1to0() { ScaleAnimation scale = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, ScaleAnimation.RELATIVE_TO_SELF, 0f, ScaleAnimation.RELATIVE_TO_SELF, 0f); scale.setDuration(3000); scale.setFillAfter(false); return scale; } /** * 伸縮動(dòng)畫(huà) 默認(rèn):相對(duì)于本身,向左上角放大年夜,大年夜無(wú)到有,動(dòng)畫(huà)時(shí)光3000,一向留在動(dòng)畫(huà)停止?fàn)顩r */ public static ScaleAnimation scaleAnimation0to1() { ScaleAnimation scale = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, ScaleAnimation.RELATIVE_TO_SELF, 0f, ScaleAnimation.RELATIVE_TO_SELF, 0f); scale.setDuration(3000); scale.setFillAfter(false); return scale; } /** * 伸縮動(dòng)畫(huà) */ /** * @param fromX * X偏向開(kāi)端縮放的角度(0-1) 0是不顯示,1是全部顯示 * @param toX * X偏向停止縮放的角度(0-1) 0是不顯示,1是全部顯示 * @param fromY * Y偏向開(kāi)端縮放的角度(0-1) 0是不顯示,1是全部顯示 * @param toY * Y偏向停止縮放的角度(0-1) 0是不顯示,1是全部顯示 * @param pivotXType * X偏向相對(duì)類型 * @param pivotXValue * X偏向相對(duì)于的值 * @param pivotYType * Y偏向相對(duì)類型 * @param pivotYValue * Y偏向相對(duì)于的值 * @param durationMillis * 動(dòng)畫(huà)履行時(shí)光 * @param fillAfter * 是否逗留在動(dòng)畫(huà)停止的狀況 * @return */ public static ScaleAnimation scaleAnimationCustom(float fromX, float toX, float fromY, float toY, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue, long durationMillis, boolean fillAfter) { ScaleAnimation scale = new ScaleAnimation(fromX, toX, fromY, toY, pivotXType, pivotXValue, pivotYType, pivotYValue); scale.setDuration(durationMillis); scale.setFillAfter(fillAfter); return scale; } /** * 平移動(dòng)畫(huà):大年夜左向右 平移 * * @return */ public static TranslateAnimation translateAnimationLeftToRight() { TranslateAnimation translate = new TranslateAnimation( TranslateAnimation.RELATIVE_TO_SELF, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 1.0f, TranslateAnimation.RELATIVE_TO_SELF, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 0.0f); translate.setDuration(3000); translate.setFillAfter(false); return translate; } /** * 平移動(dòng)畫(huà):大年夜右向左 平移 * * @return */ public static TranslateAnimation translateAnimationRightToLeft() { TranslateAnimation translate = new TranslateAnimation( TranslateAnimation.RELATIVE_TO_SELF, 1.0f, TranslateAnimation.RELATIVE_TO_SELF, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 0.0f); translate.setDuration(3000); translate.setFillAfter(false); return translate; } /** * 平移動(dòng)畫(huà):自定義 * * @return */ /** * @param fromXType * X偏向開(kāi)端平移相對(duì)類型 * @param fromXValue * X偏向開(kāi)端平移相對(duì)值 * @param toXType * X偏向停止平移相對(duì)類型 * @param toXValue * X偏向停止平移相對(duì)值 * @param fromYType * Y偏向開(kāi)端平移相對(duì)類型 * @param fromYValue * Y偏向開(kāi)端平移相對(duì)值 * @param toYType * Y偏向停止平移相對(duì)類型 * @param toYValue * Y偏向停止平移相對(duì)值 * @param durationMillis * 動(dòng)畫(huà)履行時(shí)光 * @param fillAfter * 是否逗留在動(dòng)畫(huà)停止?fàn)顩r * @return */ public static TranslateAnimation translateAnimationCustom(int fromXType, float fromXValue, int toXType, float toXValue, int fromYType, float fromYValue, int toYType, float toYValue, long durationMillis, boolean fillAfter) { TranslateAnimation translate = new TranslateAnimation(fromXType, fromXValue, toXType, toXValue, fromYType, fromYValue, toYType, toYValue); translate.setDuration(durationMillis); translate.setFillAfter(fillAfter); return translate; } /** * 動(dòng)畫(huà)集合:漸變-縮放-扭轉(zhuǎn);效不雅,大年夜里向外扭轉(zhuǎn)放大年夜 * * @return */ public static Animation animationSet() { AnimationSet aniset = new AnimationSet(true);// true表示一路起感化 aniset.addAnimation(alphaAnimation0To1()); aniset.addAnimation(AnimationCodeUtils.scaleAnimationCustom(0f, 1f, 0f, 1f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f, 3000, false)); aniset.addAnimation(rotateAnimation0to360()); return aniset; } }
源碼下載:http://download.csdn.net/detail/forwardyzk/8317823
動(dòng)畫(huà)效不雅圖:
[img]http://img.blog.csdn.net/20150104101740023?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZm9yd2FyZHl6aw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center
相關(guān)案例查看更多
相關(guān)閱讀
- 用戶登錄
- 買(mǎi)小程序被騙
- 云南網(wǎng)站建設(shè)優(yōu)化
- 商標(biāo)注冊(cè)
- 昆明網(wǎng)站制作
- 網(wǎng)絡(luò)公司聯(lián)系方式
- 網(wǎng)絡(luò)公司
- 汽車(chē)報(bào)廢管理系統(tǒng)
- 云南網(wǎng)站建設(shè)價(jià)格
- 云南網(wǎng)站建設(shè)首選公司
- 報(bào)廢車(chē)回收管理軟件
- 報(bào)廢車(chē)回收
- 云南網(wǎng)站建設(shè)制作
- 網(wǎng)站建設(shè)首選公司
- 網(wǎng)站建設(shè)首選
- 麗江小程序開(kāi)發(fā)
- 網(wǎng)站建設(shè)專業(yè)品牌
- 云南網(wǎng)站建設(shè)選
- 報(bào)廢車(chē)回收管理系統(tǒng)
- 網(wǎng)站建設(shè)列表網(wǎng)
- 云南網(wǎng)站建設(shè)案例
- 云南網(wǎng)站建設(shè)外包
- 楚雄網(wǎng)站建設(shè)公司
- 搜索引擎自然排名
- 網(wǎng)站建設(shè)方案 doc
- 云南網(wǎng)站設(shè)計(jì)
- 怎么做網(wǎng)站
- 網(wǎng)站建設(shè)案例
- 云南建設(shè)廳網(wǎng)站首頁(yè)
- 開(kāi)發(fā)微信小程序