Splash闪屏页-三种动画效果

三种动画效果

旋转 RotateAnimation

缩放 ScaleAnimation

渐变 AlphaAnimation

 

动画效果集合 

AnimationSet

 

 1 // 初始化欢迎页面的动画
 2 
 3 private void initViews(){
 4 
 5       RelativeLayout rlRoot = (RelativeLayout) findViewById(R.id.rl_root);    
 6 
 7       RotateAnimation rotate  = new RotateAnimation(0,360,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
 8       rotate.setDuration(1000);//动画执行的时间
 9       rotate.setFillAfter(true);//动画结束后保持最终状态
10 
11       ScaleAnimation scale = new ScaleAnimation(0,1,0,1,,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
12       scale.setDuration(1000);
13       scale.setFillAfter(true);
14 
15       AlphaAnimation alpha = new AlphaAnimation(0,1);
16       alpha.setDuration(1000);
17       alpha.setFillAfter(true);
18 
19       AnimationSet set = new AnimationSet(false);
20       set.addAnimation(rotate);
21       set.addAnimation(scale);
22       set.addAnimation(alpha);
23       
24       rlRoot.startAnimation(set);   
25         
26 }                          

 

转载于:https://www.cnblogs.com/lude313/p/4855438.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Flutter的闪屏可以通过Flutter的启动流程来实现。在Flutter中,应用程序的入口是main()函数,在main()函数中,我们可以使用Flutter提供的WidgetsFlutterBinding.ensureInitialized()方法来初始化Flutter的绑定。 在初始化完成后,我们可以使用Navigator.pushReplacement()方法来实现闪屏效果。具体步骤如下: 1.在main()函数中,初始化Flutter的绑定: void main() async { WidgetsFlutterBinding.ensureInitialized(); ... } 2.创建闪屏的Widget,并在Widget的build()方法中调用Navigator.pushReplacement()方法: class SplashScreen extends StatelessWidget { @override Widget build(BuildContext context) { Future.delayed(Duration(milliseconds: 3000), () { Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => HomePage()), ); }); return Scaffold( backgroundColor: Colors.white, body: Center( child: Text( 'Splash Screen', style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold), ), ), ); } } 在上面的代码中,我们使用Future.delayed()方法来延迟3秒钟,然后调用Navigator.pushReplacement()方法来跳转到主。在实际开发中,我们可以根据需要设置延迟时间。 3.在main()函数中,调用runApp()方法并传入闪屏的Widget: void main() async { WidgetsFlutterBinding.ensureInitialized(); runApp(MaterialApp(home: SplashScreen())); } 这样,当应用程序启动时,就会显示闪屏,延迟一定时间后自动跳转到主

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值