文档

Android 小程序设置进入/退出动画

更新时间:

本文中的设置仅适用于进入和退出动画,不适用于小程序内部页面跳转。

开启进入/退出动画功能

在启动小程序时添加 needAnimInTiny 参数,值为 true。示例如下:

  1. Bundle bundle = new Bundle();
  2. bundle.putBoolean("needAnimInTiny", true);
  3. MPNebula.startApp("2018080616290001", bundle);

设置进入动画

在主工程中加入动画资源文件,分别为 tiny_fading_out.xmltiny_push_up_in.xml。示例如下:

  • tiny_fading_out.xml

    1. <?xml version="1.0" encoding="utf-8"?>
    2. <!--tiny_fading_out.xml-->
    3. <set xmlns:android="http://schemas.android.com/apk/res/android"
    4. android:duration="300">
    5. <translate android:fromYDelta="0%" android:toYDelta="100%" />
    6. </set>
  • tiny_push_up_in.xml

    1. <?xml version="1.0" encoding="utf-8"?>
    2. <!--tiny_push_up_in.xml-->
    3. <set xmlns:android="http://schemas.android.com/apk/res/android"
    4. android:duration="300">
    5. <translate android:fromYDelta="100%" android:toYDelta="0%" />
    6. </set>

设置退出动画

在主工程中加入动画资源文件,分别为 tiny_fading_in.xmltiny_push_down_out.xml。示例如下:

  • tiny_fading_in.xml

    1. <?xml version="1.0" encoding="utf-8"?>
    2. <!--tiny_fading_in.xml-->
    3. <set xmlns:android="http://schemas.android.com/apk/res/android"
    4. android:duration="300">
    5. <translate android:fromYDelta="100%" android:toYDelta="0%" />
    6. </set>
  • tiny_push_down_out.xml

    1. <?xml version="1.0" encoding="utf-8"?>
    2. <!--tiny_push_down_out.xml-->
    3. <set xmlns:android="http://schemas.android.com/apk/res/android"
    4. android:duration="300">
    5. <translate android:fromYDelta="0%" android:toYDelta="100%" />
    6. </set>
  • 本页导读 (0)
文档反馈