Android笔记之活动指示器使用

1、创建类:

import android.view.View;
import android.view.animation.TranslateAnimation;

public class MoveBg {

    public static void moveFrontBg(View v, int startX, int toX, int startY, int toY) {
        TranslateAnimation anim = new TranslateAnimation(startX, toX, startY, toY);
        anim.setDuration(200);
        anim.setFillAfter(true);
        v.startAnimation(anim);
    }
}

2、调用类的方法:


ImageView img;
img
= new ImageView(this); img.setImageResource(R.drawable.tab_front_bg);  //初始化指示器的样子

        bottom_layout = (RelativeLayout) findViewById(R.id.layout_bottom);
        bottom_layout.addView(img);//将img添加到bottom_layout下面

MoveBg.moveFrontBg(img, startLeft, 0, 0, 0); startLeft = 0; //startLeft = img.getWidth(); //startLeft = img.getWidth() * 2;

 

posted @ 2013-08-26 22:45  行云有影  阅读(259)  评论(0编辑  收藏  举报