Android 向下滑动到向上和向上向下滑动

标签 android android-animation

我正在开发 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/

相关文章:

java - 和引擎库上的颜色设置

java - Android CardView 动画不正确

上面播放的Android Fragment过渡退出动画进入动画

java - 平移动画会导致 View 的填充位置发生变化,但不会导致布局发生变化

Android - 在 LinearLayout 或 RelativeLayout 中为 View 的 topMargin/bottomMargin/等设置动画

android - Android 上的同声翻译

android - 使android toast不可取消

Java 应用程序与 Android 应用程序获取不同的 IP - 为什么?

android.hardware.display.DisplayManager.getDisplays() 没有返回连接到 chromebook 的外接显示器

android - NFC标签检测