属性动画结束后跳转页面:

自定义View设置小圆点样式

public class GuideView extends View {

public GuideView(Context context) {
    super(context);
}

public GuideView(Context context, AttributeSet attrs) {
    super(context, attrs);
}

public GuideView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
}

//测量
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

//绘制

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    
    //画圆
    Paint paint = new Paint();
    paint.setColor(Color.BLUE);
    paint.setAntiAlias(true);
    canvas.drawCircle(50,50,50,paint);
}

//定位

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    super.onLayout(changed, left, top, right, bottom);
}

//监听

@Override
public boolean onTouchEvent(MotionEvent event) {
    return super.onTouchEvent(event);
}

}

MainActivity:

public class GuideActivity extends AppCompatActivity {
@BindView(R.id.Ball)
com.example.monthtest.ui.view.GuideView Ball;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_guide);
    ButterKnife.bind(this);

    ObjectAnimator move = ObjectAnimator.ofFloat(Ball, "translationY", 0, 1100f);
    ObjectAnimator scale2 = ObjectAnimator.ofFloat(Ball, "translationX",0,600f);
    AnimatorSet animset = new AnimatorSet();
    animset.play(move).with(scale2);
    animset.setDuration(3000);
    animset.start();
    // 动画监听
    animset.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animator) {

        }

        @Override
        public void onAnimationEnd(Animator animator) {
            Intent intent = new Intent(GuideActivity.this, LoginActivity.class);
            startActivity(intent);
        }

        @Override
        public void onAnimationCancel(Animator animator) {

        }

        @Override
        public void onAnimationRepeat(Animator animator) {

        }
    });
}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值