1
我對動畫中的%p單位感到困惑。 這裏是我的動畫文件的test.xml%android png動畫
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:duration="1000"
android:fillAfter="true"
android:fromXDelta="0"
android:toXDelta="0"
android:fromYDelta="50%p"
android:toYDelta="50%p" />
而且我用這個動畫,我的看法
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:layout_alignParentTop="true"
android:background="#ff2"
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/view" />
</RelativeLayout>
但是,如果我改變看法的位置居中的父,和視圖的位置後的動畫是不正確的
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:layout_centerVertical="true"
android:background="#ff2"
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/view" />
</RelativeLayout>
我認爲對於同一個父母來說,50%的p總是一樣,但結果不是。爲什麼?
看到這篇文章:http://stackoverflow.com/a/4412183/5519005 –
是50%的平均值:currentY + 50%* parentHeight? – maphongba008