Android之高仿微信“开门动画”(六)
来源:互联网 发布:软件企业取消认定 编辑:程序博客网 时间:2024/04/26 10:46
此节内容是对第(五)节内容中WhatsDoor.class类的实现。
首先是效果图:
微信的开门动画的想法真心不错,而且也非常酷炫。仔细观察,可以发现,整个开门动画里,包括3个动画过程:
1、左边的门——从右到左。
2、右边的门——从左到右。
3、中间的字——从小到大。
知道了这3个动画过程之后,就非常简单了。
对于界面布局,采用相对布局,然后在里面放置2个ImageView和1个TextView即可。
一、界面布局:
layout\whatsdoor.xml
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <ImageView android:id="@+id/imageLeft" android:scaleType="fitXY" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentLeft="true" android:src="@drawable/w_left" /> <ImageView android:id="@+id/imageRight" android:visibility="visible" android:scaleType="fitXY" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentRight="true" android:src="@drawable/w_right" /> <TextView android:id="@+id/animText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:layout_alignParentTop="true" android:layout_marginTop="35dp" android:text=" \n \n微信,是一个生活方式\n \n " android:textSize="22sp" android:textColor="#fff" /></RelativeLayout>
二、java代码,对这3个动画分别实现动画过程:
WhatsDoor.xml
package t.first;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.os.Handler;import android.view.animation.AlphaAnimation;import android.view.animation.Animation;import android.view.animation.AnimationSet;import android.view.animation.ScaleAnimation;import android.view.animation.TranslateAnimation;import android.widget.ImageView;import android.widget.TextView;public class WhatsDoor extends Activity{public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.whatsdoor); //获取控件 ImageView left = (ImageView) findViewById(R.id.imageLeft); ImageView right = (ImageView) findViewById(R.id.imageRight); TextView text = (TextView) findViewById(R.id.animText); //也可以在XML中实现 //左边动画 AnimationSet left_anim = new AnimationSet(true); //动画集合,对加入的动画都有效 TranslateAnimation left_translate = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, -1f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f); left_translate.setDuration(1500); left_anim.addAnimation(left_translate); left_anim.setStartOffset(800); left_anim.setFillAfter(true); left.startAnimation(left_anim); //右边动画 AnimationSet right_anim = new AnimationSet(true); TranslateAnimation right_translate = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, +1f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f); right_translate.setDuration(1500); right_anim.addAnimation(right_translate); right_anim.setStartOffset(800); right_anim.setFillAfter(true); right.startAnimation(right_anim); //字体动画 AnimationSet text_anim = new AnimationSet(true); ScaleAnimation text_scale = new ScaleAnimation( 1f, 3f, 1f, 3f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); text_scale.setDuration(1000); AlphaAnimation text_alpha = new AlphaAnimation(1,0.0001f); text_alpha.setDuration(1500); text_anim.addAnimation(text_scale); text_anim.addAnimation(text_alpha); text_anim.setFillAfter(true); text.startAnimation(text_anim); //延时一段时间后开启主界面 new Handler().postDelayed(new Runnable(){ public void run(){ Intent intent = new Intent (WhatsDoor.this,MainWidget.class);//进入主界面,在第(七)节内容中实现该类 startActivity(intent); WhatsDoor.this.finish(); } }, 1500); }}
<activity android:name=".WhatsDoor" android:theme="@style/Fullscreen_Notitle_Fade"/> <!-- 此自定义主题样式在第(二)节内容中有详细介绍 -->
四、所用素材:
0 0
- Android之高仿微信“开门动画”(六)
- android开门动画效果
- Android动画之AnimationListener(六)
- Android动画之AnimationListener(六)
- Android动画之AnimationListener(六)
- 开门动画
- Android动画学习(六)之View揭露效果和SurfaceView实现动画
- Android动画之旅(六)----放大镜的特效动画
- unity官方demo学习之Stealth(十五)单开门动画
- WebGL之旅(六)动画
- Android属性动画---Property Animation(六)
- Android属性动画---Property Animation(六)
- 单侧开门动画
- Android(开发):动画之Frame动画
- Android动画之属性动画(二)
- Android动画之属性动画(上)
- Android动画之属性动画(下)
- Android动画之帧动画(三)
- MYSQL常用命令
- [寒江孤叶丶的Cocos2d-x之旅_01]浅谈多平台支持的格式化字符串(字符串连接)
- 传真智能化时代的来临令业务更高效
- 配置TortoiseGit
- python zipfile压缩工具
- Android之高仿微信“开门动画”(六)
- Nginx脚本中的DESTDIR变量
- Linux 运行进程实时监控pidstat命令详解
- eclipse格式化自定义代码样式风格
- 第一天:Drools环境搭建配置
- GDB基本命令
- 调用BOS服务保存一个单据的简化示例
- 花生壳远程桌面
- 排序选择排序的数组使用