Android应用的欢迎界面动画实现
一、动画基础知识
1、动画种类: Android动画有四大类,分别是AlphaAnimation、ScaleAnimation、TranslateAnimation和RotateAnimation,功能对照如下:
AlphaAnimation 渐变透明动画效果 ScaleAnimation 渐变缩放动画效果 TranslateAnimation 画面移动动画效果 RotateAnimation 画面旋转动画效果
2 、动画实现方式:动画实现方式有两种,分别是静态设置(xml)和动态设置(java代码)
3、动画模式:动画模式有两种,一种是渐变模式(AlphaAnimation、ScaleAnimation),一种是画面模式(TranslateAnimation、RotateAnimation)。
二、动画实现
实现步骤:
- 定义动画
- 设置动画属性,如时长、起始和终止
- 播放动画
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"android:fromXScale="0.3"android:toXScale="1.2"android:fromYScale="0.3"android:toYScale="1.2"android:pivotX="50%"android:pivotY="50%"android:duration="3000"android:fillAfter="true"></scale>
然后在相应activity下编辑如下代码:
Animation anim = AnimationUtils.loadAnimation(this, R.anim.scale_animation);openWeb.startAnimation(anim);
2. 动态实现:
ScaleAnimation sa = new ScaleAnimation(0.3f, 1.2f, 0.3f, 1.2f, Animation.RELATIVE_TO_SELF, 0.5f,Animation.RELATIVE_TO_SELF,(float) 0.5);sa.setDuration(3000);sa.setFillAfter(true);openWeb.startAnimation(sa);
三、应用的欢迎动画界面实现
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"><alphaandroid:fromAlpha="0.4"android:toAlpha="1.0"android:duration="300"/><scaleandroid:fromXScale="1.0"android:toXScale="1.2"android:fromYScale="1.0"android:toYScale="1.2"android:pivotX="50%"android:pivotY="50%"android:duration="3000"></scale></set>
新建结束动画集anim_out.xml
<set xmlns:android="http://schemas.android.com/apk/res/android"><alphaandroid:fromAlpha="1"android:toAlpha="0.4"android:duration="2000"></alpha></set>
动画界面布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/welcom"android:orientation="vertical" android:layout_width="match_parent"android:layout_height="match_parent"android:fitsSystemWindows="true"android:background="@drawable/welcom"android:clipToPadding="true"></LinearLayout>
public class WelcomActivity extends AppCompatActivity {private LinearLayout welcom;Animation anim1=null;Animation anim2=null;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.activity_welcom);getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);welcom=(LinearLayout) findViewById(R.id.welcom);anim1 = AnimationUtils.loadAnimation(this,R.anim.anim_in);anim2 = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.anim_out);welcom.startAnimation(anim1);anim1.setFillEnabled(true); //启动保持anim1.setFillAfter(true);//最后一帧保持,否则会跳动到原始anim1.setAnimationListener(new AnimationImpl() {@Overridepublic void onAnimationEnd(Animation animation) {welcom.startAnimation(anim2);anim2.setFillAfter(true);}});anim2.setAnimationListener(new AnimationImpl() {@Overridepublic void onAnimationEnd(Animation animation) {skip();}});}private void skip() {startActivity(new Intent(this,LoginActivity.class));finish();}
}
abstract class AnimationImpl implements Animation.AnimationListener {@Overridepublic void onAnimationStart(Animation animation) {}@Overrideabstract public void onAnimationEnd(Animation animation);@Overridepublic void onAnimationRepeat(Animation animation) {}
}
当然,还需要在AndroidManifest.xml中设置WelcomActivity为启动项,动画这里就不贴了。
Android应用的欢迎界面动画实现相关推荐
- Android仿新浪微博弹出界面动画,Android仿新浪微博启动界面或登陆界面(1)
本文为大家分享了Android模仿新浪微博启动界面&登陆界面的具体实现代码,供大家参考,具体内容如下 启动界面 主要有两个功能: 1.加载启动动画 2.判断网络,有者直接进入登陆界面,否则去设 ...
- Android欢迎界面动画与跳转
Android中的欢迎界面是几乎每个app都需要完成的部门. 通常我们会希望再欢迎界面完成之后,Activity跳转到主界面.因此我们可以用如下的代码实现: //加载并设置动画,并实现跳转. ...
- android欢迎界面动画加载
欢迎界面 WelcomeActivity .java public class WelcomeActivity extends Activity implements AnimationListene ...
- 使用 Fries 创建性感的 Android 风格移动应用界面
Fries 是一个移动开发框架,让开发者仅使用 HTML,CSS 和 Javascript 快速创建出 Android 应用程序界面.Fries 的灵感来自于流行的 Ratchet(开发 iPhone ...
- android刷新时的圆形动画_Android自定义加载圈动画效果
本文实例为大家分享了Android自定义加载圈动画展示的具体代码,供大家参考,具体内容如下 实现如下效果: 该效果图主要有3个动画: 1.旋转动画 2.聚合动画 3.扩散动画 以上3个动画都是通过Va ...
- Android学习之登陆界面设计(一)前后期准备以及相关配置
Android学习之登陆界面设计(一)前后期准备以及相关配置 前言 成品 成品样式 成品特点 工具 系统配置 手机配置 Android Studio 3.6.3 SDK 图片来源 矢量图标库 Back ...
- Android学习之登陆界面设计(二)基本界面设计
Android学习之登陆界面设计(二)基本界面设计 前提 绘图样式 - drawable bg_login_btn_submit.xml bg_login_panel_slide.xml bg_log ...
- android 很多牛群叉界面库github地址
android 很多牛叉界面库github地址 点击可到达github-------https://github.com/Trinea/android-open-project Android开源项目 ...
- android 很多牛叉界面库github地址
点击可到达github-------https://github.com/Trinea/android-open-project 包括ListView.ActionBar.Menu.ViewPager ...
最新文章
- celery源码分析-Task的初始化与发送任务
- Java中Date各种相关用法
- 花果山第一届猿类分级考试实录--Talk is cheap,Show me the code
- 不同职业的面试着装技巧。
- 每天都有所收获_使技术保持最新状态会有所收获
- 大数据技术得发展方向如何
- 安装配置管理 之 JRE 安装和配置,以适合JAVA程序运行所具备的环境
- hadoop中java部分练习_java私塾Hadoop实战-中高级部分 之 Hadoop RestFul
- 软件测试中的接口分析,软件测试接口测试之管理类—叩丁狼分享
- 魅族u20怎么刷Android,魅族魅蓝U20/U10一键Root权限获取+USB驱动安装
- 一名合格的IT项目经理 这八项核心技能不能缺
- miredo - Teredo IPv6 tunneling for Unix
- 什么是阿尔法(Alpha)收益、贝塔(Beta)收益
- java服务器端集成微信小程序
- 贴片陶瓷电容的NPO、C0G、X7R、X5R、Y5V、Z5U区别
- FMEA学习(1总概)
- 织梦网站在空间怎么转服务器,织梦网站换空间
- 初中科学计算机使用,350MS 82MS科学计算器使用方法(初中).doc
- 手把手安装Origin软件
- Raccoon——(Reverse)EasyRE 01 writeup