1
アニメーションで%p単位について混乱しています。 は、ここに私のアニメーションファイルのtest.xml%p in android animation
<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はいつも同じだと思いますが、結果はそうではありません。どうして?あなたは
android:fromYDelta="0%p"
android:toYDelta="50%p"
を試すことができます
この投稿を参照してください:http://stackoverflow.com/a/4412183/5519005 –
は50%p平均です:currentY + 50%* parentHeight? – maphongba008