我正在开发 Dialog,我想将它从下到上和从上到下制作成动画。 我试过这段代码: bottom_up.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="500"
android:fillAfter="true"
android:fromYDelta="125%p"
android:toYDelta="0%p" />
</set>
bottom_down.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="500"
android:fillAfter="true"
android:fromYDelta="0%p"
android:interpolator="@android:anim/linear_interpolator"
android:toYDelta="100%p" />
</set>
上面的代码使对话框动画到屏幕中心。 但我需要从底部向上滑动但与底部对齐。并向下滑动。
我该怎么做?
最佳答案
尝试向下滑动:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="-200%"
android:toYDelta="0%" android:duration="1000"/>
</set>
只需将其反转即可向上滑动。
关于Android 向下滑动到向上和向上向下滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33257209/