97干视频,99国产精品懂色,亚洲精品99久久久久中文字幕,伊人五月丁香综合AⅤ,国产精品成人免费999

  您的位置:華清遠(yuǎn)見教育科技集團(tuán) >> 新聞動(dòng)態(tài) >> Android資料 >> Android 屬性動(dòng)畫開發(fā)源碼  
 
Android 屬性動(dòng)畫開發(fā)源碼
分享到:

屬性動(dòng)畫在Android 3.0中引入,為開發(fā)者提供了更強(qiáng)的自定義動(dòng)畫的能力,屬性動(dòng)畫在游戲開發(fā)中比較常見。下面是演示一副圖像的寬度的例子:

代碼:屬性動(dòng)畫的實(shí)例

package com.miaozl.test2;

import android.animation.IntEvaluator;
    import android.animation.ObjectAnimator;
    import android.animation.ValueAnimator;
    import android.app.Activity;
    import android.content.Context;
    import android.os.Bundle;
    import android.widget.ImageView;
    import android.widget.LinearLayout;

public class PropertyAnimActivity extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        LinearLayout root= ((LinearLayout) this.findViewById(R.id.animlayout));
        ImageAnimView imageAnim = new ImageAnimView(this);
        imageAnim.setImageResource(R.drawable.photo3);
        root.addView(imageAnim);
        }
        private class ImageAnimView extends ImageView {
        public ImageAnimView(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
        ValueAnimator valueAnim = ObjectAnimator.ofInt(this, "width", 0, 200);
        valueAnim.setDuration(3000); //持續(xù)時(shí)間
        valueAnim.setEvaluator(new IntEvaluator());//設(shè)置演進(jìn)器
        valueAnim.setRepeatCount(ValueAnimator.INFINITE);//設(shè)置重復(fù)數(shù)
        valueAnim.setRepeatMode(ValueAnimator.REVERSE);//設(shè)置重復(fù)模式
        valueAnim.start();
            }
        }
    }

在Android中,目前定義了三種類型的演進(jìn)器:ArgbEvaluator、FloatEvaluator、IntEvaluator等。如果用于動(dòng)畫的屬性不是int、float、color類型的。開發(fā)者可以擴(kuò)展TypeEvaluator接口來計(jì)算目標(biāo)對(duì)象的屬性變化。

 更多相關(guān)文章

·Android系統(tǒng)層次結(jié)構(gòu)及分析
·Android平板電腦的設(shè)計(jì)
·Android本地服務(wù)的啟動(dòng)
·Android項(xiàng)目的mvc模式
·Android應(yīng)用-交互式界面設(shè)計(jì)過程(四)