自定义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) {
}
});
}
}