中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

AnimationSet類:動(dòng)畫集合類

2018-07-20    來源:open-open

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬Linux鏡像隨意使用

 AnimationSet類:動(dòng)畫集合類

AnimationSet類是Android系統(tǒng)中的動(dòng)畫集合類,用于控制View對(duì)象進(jìn)行多個(gè)動(dòng)作的組合,該類繼承于Animation類。 AnimationSet類中的很多方法都與Animation類一致,該類中最常用的方法便是addAnimation方法,該方法用于為動(dòng)畫集合對(duì)象 添加動(dòng)畫對(duì)象。

【基本語法】public void addAnimation (Animation a)

其中,參數(shù)a為Animation動(dòng)畫對(duì)象,可以是前述任何一種補(bǔ)間動(dòng)作。

【實(shí)例演示】下面通過代碼來演示如何設(shè)置一個(gè)組合動(dòng)畫效果。

    public class firstActivity extends Activity {  
    /** Called when the activity is first created. */  
    @Override  
    public void onCreate(Bundle savedInstanceState) {               //重載onCreate方法  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.main);  
     
        final ImageView image=(ImageView)findViewById(R.id.imageView1); //ImageView對(duì)象  
        Button btn1=(Button)findViewById(R.id.button1);             //按鈕對(duì)象  
        Button btn2=(Button)findViewById(R.id.button2);  
        final Animation translateAnimation=new TranslateAnimation(0,300,0,300);                                                                 //設(shè)置位置變化動(dòng)畫  
        final Animation scaleAnimation = new   
         ScaleAnimation(0f,1f,0f,1f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);  
                                                                //設(shè)置尺寸變化動(dòng)畫  
        final Animation alphaAnimation=new AlphaAnimation(0.1f,1.0f);   //設(shè)置透明度變化動(dòng)畫  
        btn1.setOnClickListener(new View.OnClickListener() {            //設(shè)置監(jiān)聽器  
              
            @Override  
            public void onClick(View v) {  
                // TODO Auto-generated method stub  
                translateAnimation.setDuration(10000);      //設(shè)置位置變化動(dòng)畫的持續(xù)時(shí)間  
                scaleAnimation.setDuration(10000);          //設(shè)置尺寸變化動(dòng)畫的持續(xù)時(shí)間  
                alphaAnimation.setDuration(10000);          //設(shè)置透明度漸變動(dòng)畫的持續(xù)時(shí)間  
                AnimationSet set=new AnimationSet(true);    //創(chuàng)建動(dòng)畫集對(duì)象  
                set.addAnimation(translateAnimation);       //添加位置變化動(dòng)畫  
                set.addAnimation(scaleAnimation);           //添加尺寸變化動(dòng)畫  
                set.addAnimation(alphaAnimation);           //添加透明度漸變動(dòng)畫  
                set.setFillAfter(true);                 //停留在最后的位置  
                set.setFillEnabled(true);  
                image.setAnimation(set);                    //設(shè)置動(dòng)畫  
                set.startNow();                         //啟動(dòng)動(dòng)畫  
            }  
        });  
        btn2.setOnClickListener(new View.OnClickListener() {    //設(shè)置監(jiān)聽器  
              
            @Override  
            public void onClick(View v) {  
                // TODO Auto-generated method stub  
                set.cancel();                               //取消動(dòng)畫執(zhí)行  
            }  
        });  
    }  
    }  

標(biāo)簽: 代碼

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:Android PullToRefresh上拉和下拉刷新

下一篇:用開源項(xiàng)目PHPMailer實(shí)現(xiàn)郵件發(fā)送