WindowAnimationStyle

WindowAnimationStyle

主题中定义窗口window或Activity的进入退出动画集合,用于theme的Style,例如/res/styles.xml下

    <!-- Base application theme. -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="android:textAllCaps">false</item>
        <item name="android:windowActionBar">false</item>
        <item name="windowActionBar">false</item>
        <item name="android:windowAnimationStyle">@style/AnimationActivity</item>
        <item name="windowNoTitle">true</item>
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
    </style>

而自定义AnimationActivity如下

    <style name="AnimationActivity" parent="@android:style/Animation.Activity">
        <item name="android:activityOpenEnterAnimation">@anim/slide_in_left</item>
        <item name="android:activityOpenExitAnimation">@anim/slide_out_left</item>
        <item name="android:activityCloseEnterAnimation">@anim/slide_in_right</item>
        <item name="android:activityCloseExitAnimation">@anim/slide_out_right</item>
    </style>

其中@android:style/Animation.Activity为系统的style定义,如下

<!-- Window animation class attributes. -->
<declare-styleable name="WindowAnimation">
    <!-- The animation used when a window is being added. -->
    <attr name="windowEnterAnimation" format="reference" />
    <!-- The animation used when a window is being removed. -->
    <attr name="windowExitAnimation" format="reference" />
    <!-- The animation used when a window is going from INVISIBLE to VISIBLE. -->
    <attr name="windowShowAnimation" format="reference" />
    <!-- The animation used when a window is going from VISIBLE to INVISIBLE. -->
    <attr name="windowHideAnimation" format="reference" />

    <!--  When opening a new activity, this is the animation that is
          run on the next activity (which is entering the screen). -->
    <attr name="activityOpenEnterAnimation" format="reference" />
    <!--  When opening a new activity, this is the animation that is
          run on the previous activity (which is exiting the screen). -->
    <attr name="activityOpenExitAnimation" format="reference" />
    <!--  When closing the current activity, this is the animation that is
          run on the next activity (which is entering the screen). -->
    <attr name="activityCloseEnterAnimation" format="reference" />
    <!--  When closing the current activity, this is the animation that is
          run on the current activity (which is exiting the screen). -->
    <attr name="activityCloseExitAnimation" format="reference" />
    <!--  When opening an activity in a new task, this is the animation that is
          run on the activity of the new task (which is entering the screen). -->
    <attr name="taskOpenEnterAnimation" format="reference" />
    <!--  When opening an activity in a new task, this is the animation that is
          run on the activity of the old task (which is exiting the screen). -->
    <attr name="taskOpenExitAnimation" format="reference" />
    <!--  When opening an activity in a new task using Intent/FLAG_ACTIVITY_LAUNCH_BEHIND,
          this is the animation that is run on the activity of the new task (which is
          entering the screen and then leaving). -->
    <attr name="launchTaskBehindTargetAnimation" format="reference" />
    <!--  When opening an activity in a new task using Intent.FLAG_ACTIVITY_LAUNCH_BEHIND,
          this is the animation that is run on the activity of the old task (which is
          already on the screen and then stays on). -->
    <attr name="launchTaskBehindSourceAnimation" format="reference" />
    <!--  When closing the last activity of a task, this is the animation that is
          run on the activity of the next task (which is entering the screen). -->
    <attr name="taskCloseEnterAnimation" format="reference" />
    <!--  When opening an activity in a new task, this is the animation that is
          run on the activity of the old task (which is exiting the screen). -->
    <attr name="taskCloseExitAnimation" format="reference" />
    <!--  When bringing an existing task to the foreground, this is the
          animation that is run on the top activity of the task being brought
          to the foreground (which is entering the screen). -->
    <attr name="taskToFrontEnterAnimation" format="reference" />
    <!--  When bringing an existing task to the foreground, this is the
          animation that is run on the current foreground activity
          (which is exiting the screen). -->
    <attr name="taskToFrontExitAnimation" format="reference" />
    <!--  When sending the current task to the background, this is the
          animation that is run on the top activity of the task behind
          it (which is entering the screen). -->
    <attr name="taskToBackEnterAnimation" format="reference" />
    <!--  When sending the current task to the background, this is the
          animation that is run on the top activity of the current task
          (which is exiting the screen). -->
    <attr name="taskToBackExitAnimation" format="reference" />

    <!--  When opening a new activity that shows the wallpaper, while
          currently not showing the wallpaper, this is the animation that
          is run on the new wallpaper activity (which is entering the screen). -->
    <attr name="wallpaperOpenEnterAnimation" format="reference" />
    <!--  When opening a new activity that shows the wallpaper, while
          currently not showing the wallpaper, this is the animation that
          is run on the current activity (which is exiting the screen). -->
    <attr name="wallpaperOpenExitAnimation" format="reference" />
    <!--  When opening a new activity that hides the wallpaper, while
          currently showing the wallpaper, this is the animation that
          is run on the new activity (which is entering the screen). -->
    <attr name="wallpaperCloseEnterAnimation" format="reference" />
    <!--  When opening a new activity that hides the wallpaper, while
          currently showing the wallpaper, this is the animation that
          is run on the old wallpaper activity (which is exiting the screen). -->
    <attr name="wallpaperCloseExitAnimation" format="reference" />

    <!--  When opening a new activity that is on top of the wallpaper
          when the current activity is also on top of the wallpaper,
          this is the animation that is run on the new activity
          (which is entering the screen).  The wallpaper remains
          static behind the animation. -->
    <attr name="wallpaperIntraOpenEnterAnimation" format="reference" />
    <!--  When opening a new activity that is on top of the wallpaper
          when the current activity is also on top of the wallpaper,
          this is the animation that is run on the current activity
          (which is exiting the screen).  The wallpaper remains
          static behind the animation. -->
    <attr name="wallpaperIntraOpenExitAnimation" format="reference" />
    <!--  When closing a foreround activity that is on top of the wallpaper
          when the previous activity is also on top of the wallpaper,
          this is the animation that is run on the previous activity
          (which is entering the screen).  The wallpaper remains
          static behind the animation. -->
    <attr name="wallpaperIntraCloseEnterAnimation" format="reference" />
    <!--  When closing a foreround activity that is on top of the wallpaper
          when the previous activity is also on top of the wallpaper,
          this is the animation that is run on the current activity
          (which is exiting the screen).  The wallpaper remains
          static behind the animation. -->
    <attr name="wallpaperIntraCloseExitAnimation" format="reference" />

    <!--  When opening a new activity from a RemoteViews, this is the
          animation that is run on the next activity (which is entering the
          screen). Requires config_overrideRemoteViewsActivityTransition to
          be true. -->
    <attr name="activityOpenRemoteViewsEnterAnimation" format="reference" />

</declare-styleable>

可以还有定义系统的FragmentAnimation

    <!-- Fragment animation class attributes. -->
    <declare-styleable name="FragmentAnimation">
        <attr name="fragmentOpenEnterAnimation" format="reference" />
        <attr name="fragmentOpenExitAnimation" format="reference" />
        <attr name="fragmentCloseEnterAnimation" format="reference" />
        <attr name="fragmentCloseExitAnimation" format="reference" />
        <attr name="fragmentFadeEnterAnimation" format="reference" />
        <attr name="fragmentFadeExitAnimation" format="reference" />
    </declare-styleable>

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值