国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

屬性動畫 進階(ObjectAnimator)

2019-11-06 09:59:46
字體:
來源:轉載
供稿:網友

首先

這不是一篇介紹屬性動畫使用的文章,如何使用網上一大把,不愿意做別人做過的事情。

正文

我在看了N多介紹屬性動畫的文章后,發現所有千篇一律,諸如以下代碼(請關注第二個參數屬性名)

ObjectAnimator animator = ObjectAnimator.ofFloat(textview, "alpha", 1f, 0f, 1f); animator.setDuration(5000); animator.start(); ...ObjectAnimator animator = ObjectAnimator.ofFloat(textview, "rotation", 0f, 360f); animator.setDuration(5000); animator.start(); ...ObjectAnimator animator = ObjectAnimator.ofFloat(textview, "translationX", 0f, 360f); animator.setDuration(5000); animator.start(); ...ObjectAnimator animator = ObjectAnimator.ofFloat(textview, "translationY", 0f, 360f); animator.setDuration(5000); animator.start();

我很疑惑的是,難道我大google設計API,設計成這樣?需要開發者記住每一個屬性名嗎,需要實現一個動畫的時候,還需要先去想,這個屬性的全拼是怎么樣的,實在太扯淡。

觀察ObjectAnimator方法之后發現以下方法

ofInt(T target, PRoperty<T, Integer> property, int... values)ofInt(T target, Property<T, Integer> xProperty,Property<T, Integer> yProperty, Path path)ofFloat(T target, Property<T, Float> property, float... values)ofFloat(T target, Property<T, Float> xProperty,Property<T, Float> yProperty, Path path)...

其中第二個帶xy屬性的方法,Api21以上才有,使用起來veryEasy

//旋轉ObjectAnimator animation = ObjectAnimator.ofFloat(fabIconStar, View.ROTATION, 0f, 45f);//ObjectAnimator animation = ObjectAnimator.ofFloat(fabIconStar,View.ROTATION, 0f, 45f,0f);//轉回去ObjectAnimator animation = ObjectAnimator.ofFloat(tager, View.ROTATION, 45f, 0);//移動xyPath path = new Path(); path.lineTo(10, 10); path.lineTo(50, 20); //path.lineTo(10,10); //path.lineTo(0,0); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLipOP) { ObjectAnimator animation1 = ObjectAnimator.ofFloat(tager, View.TRANSLATION_X,View.TRANSLATION_Y, path); animation1.start(); }//移動回去 Path path = new Path(); path.moveTo(50, 20); path.lineTo(10, 10); path.lineTo(0, 0); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { ObjectAnimator animation1 = ObjectAnimator.ofFloat(tager, View.TRANSLATION_X,View.TRANSLATION_Y, path); animation1.start(); }

可使用屬性View內所有 Property 屬性,

Property<View, Float> ...

有興趣的可以一個個去嘗試一下,在這里不作詳述了。

謝謝

是不是soEasy!歡淫吐槽,指正,評論!


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 霞浦县| 砚山县| 龙山县| 香河县| 温宿县| 林周县| 邛崃市| 东宁县| 博爱县| 沙田区| 永平县| 瑞丽市| 衡东县| 改则县| 托克逊县| 浑源县| 辛集市| 霸州市| 安阳市| 蒙阴县| 许昌市| 佛学| 正安县| 安阳县| 盐池县| 兰溪市| 石门县| 拜城县| 山东| 定州市| 淮安市| 额敏县| 原平市| 彭水| 普宁市| 河津市| 荣成市| 右玉县| 曲水县| 延寿县| 大关县|