android 按钮变形动画,Android仿硬币转动微信红包动画效果

项目需要研究了一下微信红包动画 , 即硬币转动的效果 , 原理其实就是三张不同角度的图片利用帧动画进行播放 , 在参考了案例之后 , 给自己记录一下完成的过程 。
1 , 在XML文件中定义动画:
步骤如下:
①新建项目
②在目录中新建一个anim.xml(注意文件名小写)
根标签为-list , 其中代表着是否只展示一遍 , 设置为false会不停的循环播放动画根标签下 , 通过item标签对动画中的每一个图片进行声明  , : 表示展示所用的该图片的时间长度 ,可通过该参数来设置图片旋转的速度 , 其他属性可以自行查找资料~
2 , 设置布局文件 , 效果以及代码如下
:=""
:=""
:=""
:="|"
:="@/">
:id="@+id/top"
:=""
:="0dp"
:="1">
:id="@+id/close"
:="32dp"
:="32dp"
:="@/close"
:="10dp"/>
:="@+id/top"
【android 按钮变形动画,Android仿硬币转动微信红包动画效果】:=""
:="0dp"
:="10"
:="">
:=""
:="0dp"
:="3">
:id="@+id/"
:="60dp"
:="60dp"
:="@/"
:p="true"
:tal="true"/>
:id="@+id/name"
:=""
:=""
:text="系统用户"
:="10dp"
:="@+id/"
:tal="true"
:="@color/"
:="18sp"/>
:id="@+id/"
:=""
:=""
:="@+id/name"
:tal="true"
:="5dp"
:="15sp"
:="@color/"
:text="给你发了一个红包"/>
:id="@+id/"
:="@+id/"
:tal="true"
:=""
:=""
:="20dp"
:="@color/"
:="23sp"
:text="恭喜发财 , 大吉大利"/>
:=""
:="0dp"
:="3">
:id="@+id/"
:="100dp"
:="100dp"
:="@/anim"
:="50dp"
:tal="true" />
:=""
:="0dp"
:="1">
:=""
:=""
:="@/blow"
:ttom="true"
:tal="true"
:="14dp"
:id="@+id/" />
3 , 实现红包弹窗的效果 , 效果及代码如下:
步骤如下:
①自定义红包弹窗Diaog类:红色代码部分为启动动画部分
com...;
.app.;
..;
..;
...;
.view.;
.view.;
.view.;
.view.View;
.view.;
.view.;
..;
..;
/**
* 自定义红包弹窗
*byon 2017/2/20.
*/
class{
( ) {
super();
( , int theme) {
super(, theme);
class{
;
name;//发红包者的名称
;
//拆红包按钮
;
ner;
//关闭按钮
;
ener;
( , int ) {
this. = ;
/**
* Set thetitle from
* @param name
* @
*/
(int name) {
this.name = () .(name);
this;
/**
* Set thetitle from
* @param name
* @
*/
( name) {
this.name = name;
this;
/**
* Set theand it's
* @param
* @
*/
(int ,
) {
this. = ()
.();
this.ener = ;
this;
( ,
) {
this. = ;
this.ener = ;
this;
/**
* Set theand it's
* @param
* @
*/
(int ,
) {
this. = ()
.();
this.ner = ;
this;
( ,
) {
this. = ;
this.ner = ;
this;
() {

android 按钮变形动画,Android仿硬币转动微信红包动画效果

文章插图
= ()
.(.ICE);
//加载布局
final= new (,R.style.);
View= .(R..open, null);
= () .(R.id.);
//red指的是需要播放动画的控件
= ().();
.start();//启动动画