安卓Animation

[转自]http://www.360doc.com/content/13/0102/22/6541311_257754535.shtml

重要的事情说三遍

fillBefore是指动画结束时画面停留在第一帧,fillAfter是指动画结束是画面停留在最后一帧。最关键的问题是,这2个参数不能在</alpha>,</scale>,</translate>,</rotate>中设置,这是没有用的,必须在动画xml文件的</set>节点中设置。如果是代码必须在AnimationSet中设置。

fillBefore是指动画结束时画面停留在第一帧,fillAfter是指动画结束是画面停留在最后一帧。最关键的问题是,这2个参数不能在</alpha>,</scale>,</translate>,</rotate>中设置,这是没有用的,必须在动画xml文件的</set>节点中设置。如果是代码必须在AnimationSet中设置。

 

fillBefore是指动画结束时画面停留在第一帧,fillAfter是指动画结束是画面停留在最后一帧。最关键的问题是,这2个参数不能在</alpha>,</scale>,</translate>,</rotate>中设置,这是没有用的,必须在动画xml文件的</set>节点中设置。如果是代码必须在AnimationSet中设置。

其他的看我转的链接吧。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package  com.example.myapp.activity;
 
import  android.app.Activity;
import  android.os.Bundle;
import  android.view.View;
import  android.view.animation.*;
import  android.widget.Button;
import  android.widget.ImageView;
import  com.example.myapp.R;
 
/**
  * Created by admin on 15/9/9.
  */
public  class  AnimationActivity  extends  Activity  implements  View.OnClickListener{
     private  Button alpha;
     private  Button traslate;
     private  Button rotate;
     private  Button scale;
     private  Button all;
     private  Button xml;
     private  ImageView imageView;
     @Override
     protected  void  onCreate(Bundle savedInstanceState) {
         super .onCreate(savedInstanceState);
         setContentView(R.layout.animation);
         initviews();
         initListener();
     }
 
     public  void  initviews(){
         alpha = (Button)findViewById(R.id.alpha);
         traslate = (Button)findViewById(R.id.traslate);
         rotate = (Button)findViewById(R.id.rotate);
         scale = (Button)findViewById(R.id.scale);
         imageView = (ImageView)findViewById(R.id.image);
         all = (Button)findViewById(R.id.all);
         xml = (Button)findViewById(R.id.xml);
 
     }
 
     public  void  initListener(){
         alpha.setOnClickListener( this );
         traslate.setOnClickListener( this );
         rotate.setOnClickListener( this );
         scale.setOnClickListener( this );
         all.setOnClickListener( this );
         xml.setOnClickListener( this );
     }
 
     /**
      * Tween Animations的通用方法
        1、setDuration(long durationMills)
        设置动画持续时间(单位:毫秒)
        2、setFillAfter(Boolean fillAfter)
        如果fillAfter的值为true,则动画执行后,控件将停留在执行结束的状态
        3、setFillBefore(Boolean fillBefore)
        如果fillBefore的值为true,则动画执行后,控件将回到动画执行之前的状态
        4、setStartOffSet(long startOffSet)
        设置动画执行之前的等待时间
        5、setRepeatCount(int repeatCount)
        设置动画重复执行的次数
      * @param v
      */
 
     @Override
     public  void  onClick(View v) {
         switch  (v.getId()){
             case  R.id.alpha:
                 AnimationSet animationSet =  new  AnimationSet( true );
                 AlphaAnimation alphaAnimation =  new  AlphaAnimation( 0 , 0 .5f);
                 alphaAnimation.setDuration( 1000 );
                 animationSet.addAnimation(alphaAnimation);
                 animationSet.setFillAfter( true );
                 imageView.startAnimation(animationSet);
                 break ;
             case  R.id.traslate:
                 AnimationSet animationSet1 =  new  AnimationSet( true );
                 TranslateAnimation translateAnimation =  new  TranslateAnimation(
                         Animation.RELATIVE_TO_SELF, 0 ,
                         Animation.RELATIVE_TO_SELF, 1 ,
                         Animation.RELATIVE_TO_SELF, 0 ,
                         Animation.RELATIVE_TO_SELF, 1 );
                 translateAnimation.setDuration( 1000 );
                 animationSet1.addAnimation(translateAnimation);
                 imageView.setAnimation(animationSet1);
                 break ;
             case  R.id.rotate:
                 AnimationSet animationSet2 =  new  AnimationSet( true );
                 RotateAnimation rotateAnimation =  new  RotateAnimation( 0 , 360 ,Animation.RELATIVE_TO_SELF, 0 .5f,Animation.RELATIVE_TO_SELF, 0 .5f);
                 rotateAnimation.setDuration( 1000 );
                 animationSet2.addAnimation(rotateAnimation);
                 imageView.setAnimation(animationSet2);
                 break ;
             case  R.id.scale:
                 AnimationSet animationSet3 =  new  AnimationSet( true );
                 ScaleAnimation scaleAnimation =  new  ScaleAnimation( 0 , 1 , 0 , 1 ,Animation.RELATIVE_TO_SELF, 0 .5f,Animation.RELATIVE_TO_SELF, 0 .5f);
                 scaleAnimation.setDuration( 1000 );
                 animationSet3.addAnimation(scaleAnimation);
                 imageView.setAnimation(animationSet3);
                 break ;
             case  R.id.all:
                 AnimationSet animationSet4 =  new  AnimationSet( true );
                 AlphaAnimation alphaAnimation2 =  new  AlphaAnimation( 0 , 1 );
                 alphaAnimation2.setDuration( 1000 );
                 animationSet4.addAnimation(alphaAnimation2);
 
                 TranslateAnimation translateAnimation2 =  new  TranslateAnimation(
                         Animation.RELATIVE_TO_SELF, 0 ,
                         Animation.RELATIVE_TO_SELF, 0 .5f,
                         Animation.RELATIVE_TO_SELF, 0 ,
                         Animation.RELATIVE_TO_SELF, 0 .5f);
                 translateAnimation2.setDuration( 1000 );
                 animationSet4.addAnimation(translateAnimation2);
 
                 RotateAnimation rotateAnimation2 =  new  RotateAnimation( 0 , 360 ,Animation.RELATIVE_TO_SELF, 0 .5f,Animation.RELATIVE_TO_SELF, 0 .5f);
                 rotateAnimation2.setDuration( 1000 );
                 animationSet4.addAnimation(rotateAnimation2);
 
                 ScaleAnimation scaleAnimation2 =  new  ScaleAnimation( 0 , 1 , 0 , 1 ,Animation.RELATIVE_TO_SELF, 0 .5f,Animation.RELATIVE_TO_SELF, 0 .5f);
                 scaleAnimation2.setDuration( 1000 );
                 animationSet4.addAnimation(scaleAnimation2);
 
                 imageView.setAnimation(animationSet4);
                 break ;
             case  R.id.xml:
                 Animation animation = AnimationUtils.loadAnimation( this ,R.anim.animation);
                 imageView.startAnimation(animation);
                 break ;
         }
 
     }
}

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version= "1.0"  encoding= "utf-8" ?>
         android:interpolator= "@android:anim/accelerate_interpolator"
         android:shareInterpolator= "true"
         android:fillAfter= "true" >
     <alpha android:duration= "1000"
            android:fromAlpha= "0.0"
            android:toAlpha= "0.3" ></alpha>
     <rotate android:duration= "1000"
             android:fromDegrees= "0"
             android:toDegrees= "360"
             android:pivotX= "50%"
             android:pivotY= "50%" ></rotate>
     <scale android:duration= "1000"
            android:fromXScale= "0"
            android:toXScale= "1.0"
            android:fromYScale= "0"
            android:toYScale= "1.0"
            android:pivotX= "50%"
            android:pivotY= "50%" ></scale>
</set>

基于Swin Transformer与ASPP模块的图像分类系统设计与实现 本文介绍了一种结合Swin Transformer与空洞空间金字塔池化(ASPP)模块的高效图像分类系统。该系统通过融合Transformer的全局建模能力和ASPP的多尺度特征提取优势,显著提升了模型在复杂场景下的分类性能。 模型架构创新 系统核心采用Swin Transformer作为骨干网络,其层次化窗口注意力机制能高效捕获长距离依赖关系。在特征提取阶段,创新性地引入ASPP模块,通过并行空洞卷积(膨胀率6/12/18)和全局平均池化分支,实现多尺度上下文信息融合。ASPP输出经1x1卷积降维后与原始特征拼接,有效增强了模型对物体尺寸变化的鲁棒性。 训练优化策略 训练流程采用Adam优化器(学习率0.0001)和交叉熵损失函数,支持多GPU并行训练。系统实现了完整的评估指标体系,包括准确率、精确率、召回率、特异度和F1分数等6项指标,并通过动态曲线可视化模块实时监控训练过程。采用早停机制保存最佳模型,验证集准确率提升可达3.2%。 工程实现亮点 1. 模块化设计:分离数据加载、模型构建和训练流程,支持快速迭代 2. 自动化评估:每轮训练自动生成指标报告和可视化曲线 3. 设备自适应:智能检测CUDA可用性,无缝切换训练设备 4. 中文支持:优化可视化界面的中文显示与负号渲染 实验表明,该系统在224×224分辨率图像分类任务中,仅需2个epoch即可达到92%以上的验证准确率。ASPP模块的引入使小目标识别准确率提升15%,特别适用于医疗影像等需要细粒度分类的场景。未来可通过轻量化改造进一步优化推理速度。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值