Animations
動畫系統(tǒng):Developer-Animation
Android框架提供了兩個動畫系統(tǒng):屬性動畫和視圖動畫劲适。兩個動畫系統(tǒng)都是可行的選擇齐板,但是總的來說采章,屬性動畫系統(tǒng)是首選的方法景鼠,因為它更靈活仲翎,提供了更多的特性痹扇。
android3.0之后 動畫分類如圖:
接下來我們具體講解這三種動畫:
一、視圖動畫:【ViewAnimation】
1. 幀動畫(FrameAnimation):它允許您加載可繪制的資源溯香,并將它們顯示為一個接一個的幀鲫构。一幀一幀的動畫,加載一系列Drawable資源來創(chuàng)建動畫玫坛,這種傳統(tǒng)動畫某種程度上就是創(chuàng)建不同圖片序列结笨,順序播放,就像電影膠片湿镀、幻燈片一樣炕吸。(這種確實很簡單,直接使用UI切好的圖就行勉痴,但是圖片過多赫模,也十分容易內存溢出oom,所以一般不建議使用)
2. 補間動畫(TweenAnimation) :AlphaAnimation(xml中alpha標簽)蒸矛, RotateAnimation(xml中rotate標簽)瀑罗, ScaleAnimation(xml中scale標簽), TranslateAnimation(xml中translate標簽)莉钙,分別對應透明度、旋轉筛谚、縮放磁玉、位移四種變化。
使用方式一:xml定制動畫(文件處于res/anim/地址下)
-
alpha xml 淡入效果
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="500" />
</set>
<!--
fromAlpha:開始時透明度
toAlpha: 結束時透明度
duration:動畫持續(xù)時間 -->
-
rotate.xml 旋轉效果:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromDegrees="300"
android:toDegrees="-360"
android:pivotX="10%"
android:pivotY="100%"
android:duration="10000" />
</set>
<!--
fromDegrees 動畫開始時的角度
toDegrees 動畫結束時物件的旋轉角度,正代表順時針
pivotX 屬性為動畫相對于物件的X坐標的開始位置
----旋轉中心的x坐標驾讲,浮點數(shù)或是百分比蚊伞。浮點數(shù)表示相對于Object的左邊緣,如5; 百分比表示相對于Object的左邊緣吮铭,如5%; 另一種百分比表示相對于父容器的左邊緣时迫,如5%p; 一般設置為50%表示在Object中心
pivotY 屬性為動畫相對于物件的Y坐標的開始位置
--- 旋轉中心的Y坐標,浮點數(shù)或是百分比谓晌。浮點數(shù)表示相對于Object的上邊緣掠拳,如5; 百分比表示相對于Object的上邊緣,如5%; 另一種百分比表示相對于父容器的上邊緣纸肉,如5%p; 一般設置為50%表示在Object中心
duration 持續(xù)時間溺欧,表示從android:fromDegrees轉動到android:toDegrees所花費的時間,單位為毫秒柏肪。1000ms=1s 可以用來計算速度姐刁。
interpolator表示變化率,但不是運行速度烦味。一個插補屬性聂使,可以將動畫效果設置為加速,減速,勻速柏靶,反復弃理,反彈等。默認為開始和結束慢中間快.
其他:
android:repeatCount 重復的次數(shù)宿礁,默認為0案铺,必須是int,可以為-1表示不停止
android:repeatMode 重復的模式梆靖,默認為restart控汉,即重頭開始重新運行,可以為reverse即從結束開始向前重新運行返吻。在android:repeatCount大于0或為infinite時生效
android:detachWallpaper 表示是否在壁紙上運行
android:startOffset 在調用start函數(shù)之后等待開始運行的時間姑子,單位為毫秒,若為10测僵,表示10ms后開始運行
android:zAdjustment 表示被animated的內容在運行時在z軸上的位置街佑,默認為normal。
normal保持內容當前的z軸順序
top運行時在最頂層顯示
bottom運行時在最底層顯示
-->
-
scale.xml 縮放效果:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:interpolator= "@android:anim/decelerate_interpolator"
android:fromXScale="0.0"
android:toXScale="1.5"
android:fromYScale="0.0"
android:toYScale="1.5"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="0"
android:duration="10000"
android:repeatCount="1"
android:repeatMode="reverse" />
</set>
<!--
fromXDelta,fromYDelta 起始時X捍靠,Y座標,屏幕右下角的座標是X:320,Y:480
toXDelta沐旨, toYDelta 動畫結束時X,Y的座標 --> <!--
interpolator 指定動畫插入器
常見的有加速減速插入器 accelerate_decelerate_interpolator
加速插入器 accelerate_interpolator,
減速插入器 decelerate_interpolator榨婆。
fromXScale,fromYScale磁携, 動畫開始前X,Y的縮放,0.0為不顯示良风, 1.0為正常大小
toXScale谊迄,toYScale, 動畫最終縮放的倍數(shù)烟央, 1.0為正常大小统诺,大于1.0放大
pivotX, pivotY 動畫起始位置疑俭,相對于屏幕的百分比,兩個都為50%表示動畫從屏幕中間開始
startOffset粮呢, 動畫多次執(zhí)行的間隔時間,如果只執(zhí)行一次钞艇,執(zhí)行前會暫停這段時間鬼贱,
單位毫秒 duration,一次動畫效果消耗的時間香璃,單位毫秒这难,
值越小動畫速度越快 repeatCount,動畫重復的計數(shù)葡秒,動畫將會執(zhí)行該值+1次
repeatMode姻乓,動畫重復的模式嵌溢,reverse為反向,當?shù)谂即螆?zhí)行時蹋岩,動畫方向會相反赖草。
restart為重新執(zhí)行,方向不變 -->
-
translate.xml 移動效果:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="320"
android:toXDelta="0"
android:fromYDelta="480"
android:toYDelta="0"
android:duration="10000" />
</set>
<!--
fromXDelta,fromYDelta 起始時X剪个,Y座標,屏幕右下角的座標是X:320,Y:480
toXDelta秧骑, toYDelta 動畫結束時X,Y的座標 -->
加載xml動畫:
//xml動畫文件
ImageView imageBg = (ImageView) content.findViewById(R.id.imageView);
Animation animation = AnimationUtils.loadAnimation(context, R.anim.splash_scale);
animation.setInterpolator(new LinearInterpolator());
imageBg.startAnimation(animation);
使用方式二、java代碼方式實現(xiàn)定制并加載動畫
xml里有的動畫屬性都可以通過java代碼創(chuàng)建扣囊。根據需要定制自己的動畫
//平移動畫 四個參數(shù)fromX,toX,fromY,toY乎折。而這個X,Y都是相對于當前這個控件的位置來說的侵歇。
//就是從當前控件的(X+fromX骂澄,Y+fromY)移動到(X+toX,Y+toY),
//(其中這個X和Y是最剛開始這個控件的X和Y坐標惕虑。就是動畫都還沒開始的時候的坐標坟冲。)
ImageView imageBg = (ImageView) content.findViewById(R.id.imageView);
TranslateAnimation anim = new TranslateAnimation(0,100,0,100);
anim.setDuration(5000);
anim.setInterpolator(new LinearInterpolator());
anim.setFillAfter(true);
imageBg .startAnimation(anim);
AnimationListener和AnimationSet
通過AnimationListener可以監(jiān)聽Animation的運行過程,有三個方法分別是Animation開始的時候調用溃蔫,完成的時候調用健提,重復的時候調用。
AnimationSet伟叛,動畫集合私痹。 我們最常用的是調用其 addAnimation 將一個個不一樣的動畫組織到一起來,然后調用view 的 startAnimation 方法觸發(fā)這些動畫執(zhí)行痪伦。
AnimationSet as=new AnimationSet(true);
RotateAnimation al=new RotateAnimation(0,-720,Animation.RELATIVE_TO_PARENT,0.5f,Animation.RELATIVE_TO_PARENT,0.5f);
al.setDuration(3000);
al.setAnimationListener(new AnimationListener(){
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
}
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
});
as.addAnimation(al);
iv.startAnimation(as);
setAnimation和startAnimation區(qū)別
setAnimation是告訴該控件我待會要執(zhí)行什么動畫侄榴,而要執(zhí)行的的動畫相种,是需要手動添加的之众。并且需要父view在動畫快要開啟的時候扎瓶,調用invalidate。需要一定的條件限制辉哥。
而startAnimation告訴該控件,我要立馬執(zhí)行該動畫攒射,該動畫就是已經設置好的動畫醋旦。調用它時就會立即開始動畫。
屬性動畫 【PropertyAnimation】
對比
ViewAnimation本身是通過改變View的繪制方式來實現(xiàn)動畫的会放,View對象本身的屬性值并沒有改變饲齐,對象仍然停留在原始位置.
Property Animation系統(tǒng)可以通過修改 View 對象實際的屬性值(屬性會有相應的 getter、setter )來實現(xiàn)屏幕上的動畫效果咧最。此外捂人,當屬性值發(fā)生變化時御雕,Views 也會自動調用 invalidate() 方法來刷新屏幕。
View Animation相當簡單滥搭,不過只能支持簡單的縮放酸纲、平移、旋轉瑟匆、透明度基本的動畫和幀動畫闽坡,且有一定的局限性。比如:
- 你希望View有一個顏色的切換動畫愁溜;
- 你希望可以使用3D旋轉動畫疾嗅;
- 你希望當動畫停止時,View的位置就是當前的位置祝谚;
- 修改組件的背景顏色
這些View Animation都無法做到宪迟。
這也就是Property Animation產生的原因。
PropertyAnimation就是通過動畫的方式改變對象的屬性交惯。
接下來我們詳細講解PropertyAnimation次泽。
1.PropertyAnimation-沿一定時間順序,通過改變View的屬性席爽,從而得到動畫效果意荤。使得“眼見為實”,動畫之后只锻,Object對象的屬性值被實實在在的改變了玖像。Property animation能夠通過改變View對象的實際屬性來實現(xiàn)View動畫,任何時候View屬性的改變齐饮,View能自動調用invalidate()來實時刷新捐寥。
2.總的來說,屬性動畫就是祖驱,動畫的執(zhí)行類
來設置動畫操作的對象的屬性
(持續(xù)時間握恳,開始和結束的屬性值,時間差值等)捺僻,然后系統(tǒng)會根據設置的參數(shù)
動態(tài)的變化對象的屬性乡洼。
- 動畫的執(zhí)行類:
- ObjectAnimator
- ValueAnimator
- 對象的屬性:
- Duration:動畫的持續(xù)時間,默認300ms
- Time Interpolation : 時間插值【LinearInterpolator匕坯、AccelerateInterpolator束昵、DecelerateInterpolator等】
- Repeat count and behavior:重復次數(shù)、以及重復模式葛峻;可以定義重復多少次锹雏;重復時從頭開始,還是反向术奖。
- Animator sets : 動畫集合礁遵,你可以定義一組動畫匿辩,一起執(zhí)行或者順序執(zhí)行。
- 其他重要的類:
- AnimatorInflater 用戶加載屬性動畫的xml文件
- TypeEvaluator 類型估值榛丢,主要用于設置動畫操作屬性的值铲球。
- TimeInterpolator 時間插值
- AnimatorSet 用于控制一組動畫的執(zhí)行:線性,一起晰赞,每個動畫的先后執(zhí)行等稼病。
- PropertyValuesHolder 針對同一個對象多個屬性,同時作用多種動畫
接下來講解屬性動畫在實踐中的使用:
【關于Interpolator掖鱼、TypeEvaluator】
參看這篇文章:Android動畫之Interpolator插補器和TypeEvaluator估值器
【關于Animator監(jiān)聽器 】
Property Animation提供了Animator.AnimatorListener和Animator.AnimatorUpdateListener兩個監(jiān)聽器用于動畫在播放過程中的重要動畫事件然走。下面是兩個監(jiān)聽器接口和方法的一些介紹和說明:
- Animator.AnimatorListener:
onAnimationStart() —— 動畫開始時調用;
onAnimationEnd() —— 動畫結束時調用戏挡;
onAnimationRepeat() —— 動畫循環(huán)播放時調用芍瑞;
onAnimationCancel() —— 動畫被取消時調用。不管終止的方式如何褐墅,被取消的動畫仍然會調onAnimationEnd()拆檬;- 此監(jiān)聽器還有一個子類AnimatorListenerAdapter,兩者的區(qū)別是AnimatorListener的方法需要全部實現(xiàn)妥凳,而AnimatorListenerAdapter可以選擇我們所需要的方法實現(xiàn)竟贯,比如通常情況我們只關心onAnimationEnd。
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
}
});
animator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
- Animator.AnimatorUpdateListener(通常和ValueAnimator搭配使用):
onAnimationUpdate() —— 動畫每播放一幀時調用逝钥。
在動畫過程中屑那,可偵聽此事件來獲取并使用 ValueAnimator 計算出來的屬性值;
利用傳入事件的 ValueAnimator 對象,調用其 getAnimatedValue() 方法即可獲取當前的屬性值艘款。如果使用ValueAnimator來實現(xiàn)動畫的話 持际,則必需實現(xiàn)此偵聽器。
【關于AnimatorInflater】
上面講到ViewAnimation有許多xml加載哗咆,當然PropertyAnimation也可以對應xml加載蜘欲,位置為res/animator/
animator.xml
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000"
android:propertyName="alpha"
android:valueFrom="0.1"
android:valueTo="1.0"
android:valueType="floatType" />
調用就用到了AnimatorInflater類了
Animator animator = AnimatorInflater.loadAnimator(getApplicationContext(), R.animator.animator);
animator.setTarget(imageView);
animator.start();
組合動畫也可以xml加載
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="together">
orderring屬性設置為together,還有另一個值:sequentially(表示一個接一個執(zhí)行)岳枷。
<objectAnimator
android:duration="1000"
android:propertyName="scaleX"
android:valueFrom="1"
android:valueTo="0.5" />
<objectAnimator
android:duration="1000"
android:propertyName="scaleY"
android:valueFrom="1"
android:valueTo="0.5" />
</set>
【關于動畫屬性值】
在 Android 3.0 中給 View 增加了一些新的屬性以及相應的 getter芒填、setter 方法呜叫。Property Animation系統(tǒng)可以通過修改 View 對象實際的屬性值來實現(xiàn)屏幕上的動畫效果空繁。此外,當屬性值發(fā)生變化時朱庆,Views 也會自動調用 invalidate() 方法來刷新屏幕盛泡。 View 類中新增的便于實現(xiàn) property 動畫的屬性包括:
- translationX和translationY:增量控制view的坐標偏移
- rotation、rotationX 和 rotationY:這三個屬性控制著 2D 旋轉角度(rotation屬性)和圍繞某樞軸點的 3D 旋轉角度;
- scaleX娱颊、scaleY:控制view繞支點進行2D縮放
- x 和 y:這是指 View 在容器內的最終位置傲诵,等于 View 左上角相對于容器的坐標加上 translationX 和 translationY 后的值;
- alpha:表示 View 的 alpha 透明度凯砍。缺省值為 1 (不透明),為 0 則表示完全透明(看不見);
上述我們提到的屬性也就是接下來ObjectAnimator使用中的第二個參數(shù)拴竹,操作對象的屬性值悟衩。
當然我們也可以自定義view的動畫屬性,但必須帶有一個 setter 方法(以駱駝拼寫法命名)栓拜,格式類似 set<propertyName>()座泳。 因為 ObjectAnimator 會在動畫期間自動更新屬性值,它必須能夠用此 setter 方法訪問到該屬性幕与。getter不是必須挑势,而什么時候必須需要getter方法呢?如果在調用 ObjectAnimator 的某個工廠方法時啦鸣,我們只為 values... 參數(shù)指定了一個值潮饱,那此值將被認定為動畫屬性的結束值。 這樣的話诫给,動畫顯示的屬性必須帶有一個 getter 方法香拉,用于獲取動畫的起始值。 此 getter 方法必須以get<propertyName>()的格式命名中狂。
【使用ObjectAnimator實現(xiàn)動畫】
-
關于使用ObjectAnimator實現(xiàn)動畫的步驟和實踐
1.通過調用ofFloat()缕溉、ofInt()等方法創(chuàng)建ObjectAnimator對象,并設置目標對象吃型、需要改變的目標屬性名证鸥、初始值和結束值;
2.設置動畫的持續(xù)時間勤晚、是否重復及重復次數(shù)等屬性枉层;
3.啟動動畫。
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(imageView, "translationX", 300);
objectAnimator1.setInterpolator(new AccelerateInterpolator());
objectAnimator1.setDuration(2000);
objectAnimator.setRepeatCount(ValueAnimator.INFINITE);//Animation.INFINITE 表示重復多次
objectAnimator.setRepeatMode(ValueAnimator.RESTART);//RESTART表示從頭開始赐写,REVERSE表示從末尾倒播
objectAnimator1.start();
1 . 第一個參數(shù):設置目標對象鸟蜡,即操縱的view
2 . 第二個參數(shù):設置操作的動畫的屬性值(見上面講解的動畫屬性值)
3 . 第三個參數(shù):可變數(shù)組參數(shù) (初始值,中間值挺邀,結束值)揉忘。可以有一個到N個端铛,如果是一個值的話默認這個值是動畫過渡值的結束值泣矛。如果有N個值,動畫就在這N個值之間過渡禾蚕。
【使用ValueAnimator實現(xiàn)動畫】
-
關于使用ValueAnimator實現(xiàn)動畫的步驟及實踐
那一般使用ValueAnimator實現(xiàn)動畫分為以下七個步驟:
1. 調用ValueAnimation類中的ofInt(int...values)您朽、ofFloat(String propertyName,float...values)等靜態(tài)方法實例化ValueAnimator對象,并設置目標屬性的屬性名换淆、初始值或結束值等值;
2.調用addUpdateListener(AnimatorUpdateListener mListener)方法為ValueAnimator對象設置屬性變化的監(jiān)聽器;
3.創(chuàng)建自定義的Interpolator哗总,調用setInterpolator(TimeInterpolator value)為ValueAniamtor設置自定義的Interpolator;(可選几颜,不設置默認為缺省值)
4.創(chuàng)建自定義的TypeEvaluator,調用setEvaluator(TypeEvaluator value)為ValueAnimator設置自定義的TypeEvaluator;(可選,不設置默認為缺省值)
5.在AnimatorUpdateListener 中的實現(xiàn)方法為目標對象的屬性設置計算好的屬性值讯屈。
6.設置動畫的持續(xù)時間蛋哭、是否重復及重復次數(shù)等屬性;
7.為ValueAnimator設置目標對象并開始執(zhí)行動畫。
【ObjectAnimator和ValueAnimator的對比】
- ObjectAnimator類作為ValueAnimator的子類不僅繼承了ValueAnimator的所有方法和特性涮母,并且還封裝很多實用的方法具壮,方便開發(fā)人員快速實現(xiàn)動畫。
- ObjectAnimator屬性值會自動更新哈蝇,使用ObjectAnimator實現(xiàn)動畫不需要像ValueAnimator那樣必須實現(xiàn) ValueAnimator.AnimatorUpdateListener 棺妓,因此實現(xiàn)任意對象的動畫顯示就更加容易了。
- ValueAnimator并沒有在屬性上做操作,不需要操作的對象的屬性一定要有getter和setter方法炮赦,你可以自己根據當前動畫的計算值怜跑,來操作任何屬性。
【PropertyValuesHolder】
針對同一個對象多個屬性性芬,同時作用多種動畫
PropertyValuesHolder propertyValuesHolder1 = PropertyValuesHolder.ofFloat("translationX", 300f);
PropertyValuesHolder propertyValuesHolder2 = PropertyValuesHolder.ofFloat("alpha", 1f, 0.5f);
PropertyValuesHolder propertyValuesHolder3 = PropertyValuesHolder.ofFloat("scaleX", 1f, 0, 1f);
PropertyValuesHolder propertyValuesHolder4 = PropertyValuesHolder.ofFloat("scaleY", 1f, 0, 1f);
ObjectAnimator.ofPropertyValuesHolder(imageView, propertyValuesHolder1, propertyValuesHolder2, propertyValuesHolder3, propertyValuesHolder4)
.setDuration(5000).start();
【關于AnimatorSet動畫集合】
可以調用其playTogether(同時執(zhí)行)、playSequentially(順序執(zhí)行)剧防、play植锉、before、with峭拘、after 等方法設置動畫的執(zhí)行順序俊庇,然后調用其start 觸發(fā)動畫執(zhí)行。
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(imageView, "alpha", 1f, 0.5f);
ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(imageView, "translationY", 300);
ObjectAnimator objectAnimator3 = ObjectAnimator.ofFloat(imageView, "scaleX", 1f, 0, 1f);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.setDuration(5000);
animatorSet.playTogether(objectAnimator1, objectAnimator2,objectAnimator3);
animatorSet.start();
AnimatorSet 和 AnimationSet 區(qū)別
AnimationSet 與 AnimatorSet 最大的不同在于:
AnimationSet 使用的是 Animation 子類鸡挠、AnimatorSet 使用的是 Animator 的子類辉饱。
-----Animation 是針對視圖外觀的動畫實現(xiàn),動畫被應用時外觀改變但視圖的觸發(fā)點不會發(fā)生變化拣展,還是在原來定義的位置彭沼。 (也就是作用于視圖動畫)
-----Animator 是針對視圖屬性的動畫實現(xiàn),動畫被應用時對象屬性產生變化备埃,最終導致視圖外觀變化姓惑。(也就是作用于屬性動畫)
AnimatorSet 和 PropertyValuesHolder 區(qū)別
--- AnimatorSet可以將作用于多個view多個屬性的動畫集合起來,而PropertyValuesHolder針對同一個對象多個屬性按脚。
--- AnimatorSet多了playTogether(同時執(zhí)行)于毙、playSequentially(順序執(zhí)行)、play(objectAnimator1).with(objectAnimator2)乘寒、before望众、after這些方法協(xié)同工作匪补。
【關于View的animate方法】
Android 3.0后伞辛,谷歌給View增加animate方法直接驅動屬性動畫烂翰。
可以直接這樣寫就完成了imageview 的透明度有1-0.5以及位置移動到300動畫:
imageView.animate()
.alpha(0.5f)
.y(300)
.setDuration(2000);
此后在SDK12蚤氏,SDK16又分別添加了withStartAction和withEndAction用于在動畫前甘耿,和動畫后執(zhí)行一些操作。
當然也可以.setListener(listener)等操作
imageView.animate()//
.alpha(0)// 由1到0
.y(mScreenHeight / 2)
.setDuration(1000)
// need API 12
.withStartAction(new Runnable()
{
@Override
public void run()
{
}
// need API 16
}).withEndAction(new Runnable()
{
@Override
public void run()
{
runOnUiThread(new Runnable()
{
@Override
public void run()
{
imageView.setY(0);
imageView.setAlpha(1.0f);
}
});
}
}).start();
其實上面的這段操作通過PropertyValuesHolder也可以實現(xiàn):
PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("alpha", 1f,
0f, 1f);
PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("y", 0,
mScreenHeight / 2, 0);
ObjectAnimator.ofPropertyValuesHolder(imageView, pvhX, pvhY).setDuration(1000).start();