当前位置:   article > 正文

startActivity 添加动画_startactivity 动画

startactivity 动画

ActivityOptions opts = ActivityOptions.makeCustomAnimation(this, R.anim.task_open_enter, R.anim.no_anim);

Bundle optsBundle = opts.toBundle();

startActivity(intent, optsBundle);

res/anim

task_open_enter.xml

<?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="http://schemas.android.com/apk/res/android"
        android:background="#ff000000" android:shareInterpolator="false" android:zAdjustment="top">

    <alpha android:fromAlpha="0" android:toAlpha="1.0"
            android:fillEnabled="true" android:fillBefore="true" android:fillAfter="true"
            android:interpolator="@interpolator/decelerate_quart"
            android:startOffset="0"
            android:duration="167"/>

    <translate android:fromYDelta="110%" android:toYDelta="0"
            android:fillEnabled="true" android:fillBefore="true" android:fillAfter="true"
            android:interpolator="@interpolator/decelerate_quint"
            android:startOffset="0"
            android:duration="417" />
</set>


no_anim.xml

<?xml version="1.0" encoding="utf-8"?>

<alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="417" />


res/interpolator

decelerate_quart.xml

<?xml version="1.0" encoding="utf-8"?>

<decelerateInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
        android:factor="2" />


decelerate_quint.xml

<?xml version="1.0" encoding="utf-8"?>

<decelerateInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
        android:factor="2.5" />



加上动画启动activity,在视觉上会快上很多。

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/812848?site
推荐阅读
相关标签
  

闽ICP备14008679号