首页 > 其他分享 >intent跳转时添加动画效果实例

intent跳转时添加动画效果实例

时间:2022-11-11 11:34:00浏览次数:45  
标签:动画 anim 300 50% interpolator intent 跳转 duration android


系统默认的intent跳转效果非常生硬,丑陋,影响用户体验,怎么添加跳转动画呢?

首先新建两个动画文件:

zoomin.xml:

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator">
<scale android:fromXScale="0.1" android:toXScale="1.0"
android:fromYScale="0.1" android:toYScale="1.0"
android:pivotX="50%p" android:pivotY="50%p"
android:duration="300" />
<!-- 这里为了看到动画演示效果,把动画持续时间设为3秒 -->
<alpha
android:fromAlpha="0.1"
android:toAlpha="1.0"
android:duration="300" />
</set>

zoomout.xml

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator"
android:zAdjustment="top">
<scale android:fromXScale="1.0" android:toXScale=".5"
android:fromYScale="1.0" android:toYScale=".5"
android:pivotX="50%p" android:pivotY="50%p"
android:duration="300" />
<!-- 系统内置的动画持续时间
android:duration="@android:integer/config_mediumAnimTime"
-->
<alpha android:fromAlpha="1.0" android:toAlpha="0"
android:duration="300"/>
</set>

然后只需在startActivity(intent)后面添加一句:

overridePendingTransition(R.anim.zoomin, R.anim.zoomout);

即可实现跳转动画效果,可以试试。

标签:动画,anim,300,50%,interpolator,intent,跳转,duration,android
From: https://blog.51cto.com/u_15866446/5843760

相关文章

  • SVG动画之AnimatedVectorDrawable学习以及使用
    LZ-Says:伙计,一路走来,走散了一些人,留下了最真的人,切勿悲伤,切勿心寒。抬起头,微笑继续向前行~前言上一篇,我们了解了SVG以及静态Vector图像使用,坐标地址如下:​​AndroidStudy......
  • iOS开发_UITableViewCell动画
    -(void)tableView:(UITableView*)tableViewwillDisplayCell:(UITableViewCell*)cellforRowAtIndexPath:(NSIndexPath*)indexPath{cell.transform=CGA......
  • simpread-(128 条消息) 【three.js 学习笔记(1)】读取 blender 模型并导入动画_orangecs
    本文由简悦SimpRead转码,原文地址blog.csdn.net之前尝试过使用vtk.js在浏览器上绘制三维图形。其与VTKC++版接口类似,上手较快,但vtk.js相对更新较慢,接口功能不完善......
  • 学习笔记-Flutter 动画详解(一)
    Flutter动画详解(一)本文主要介绍了动画的原理相关概念,对其他平台的动画做了一个简要的梳理,并简要的介绍了Flutter动画的一些知识。1.动画介绍动画对于App来说,非常的......
  • 学习笔记-Flutter 动画详解(二)
    Flutter动画详解(二)本文通过代码层面去分析Flutter动画的实现过程,介绍了Flutter中的Animation库以及Physics库。1.介绍本文会从代码层面去介绍Flutter动画,因此不会涉......
  • 动画系统-Legacy
    Legacy系统,也称为旧版动画系统,即用Animation控制动画(animationtype为Legacy),当动画效果不涉及交互时,可用Animation编辑器完成打开方式:window-Animation或CTRL+6 Anim......
  • win10下双击py文件无反应,cmd命令行敲python跳转至应用商店
    原因python安装目录没有添加至环境变量解决办法将python安装目录添加至系统环境变量PATH中"我的电脑"--->"属性"--->"高级"--->"环境变量"--->"系统变量"--->"PATH"......
  • 什么情况下发送ajax会触发页面跳转
    button标签没有加type属性,因为浏览器会认为button按钮默认类型是submit 会提交数据 请始终为按钮规定type属性。InternetExplorer的默认类型是"button",而其他浏......
  • C# GDI+ 画心形 跳动动画
    最近听说什么国产神剧的期中考试画心形题很火,打算跟风用C#复刻一下先看看效果:话不多说直接上代码publicForm1(){DoubleBuffered=tru......
  • #yyds干货盘点#【愚公系列】2022年11月 微信小程序-导航(跳转)
    前言1.navigatornavigator是页面跳转的标签,具体参数如下:属性类型默认值必填说明最低版本targetstringself否在哪个目标上发生跳转,默认当前小程序2.0.7......