Code example for ColorDrawable

Methods: setBackgroundDrawable

0
    private ObjectAnimator mAnimator;
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setBackgroundDrawable(new ColorDrawable(0xffffffff));
        final LinesView view = new LinesView(this);
        setContentView(view);
 
        mAnimator = ObjectAnimator.ofFloat(view, "offset", 0.0f, 15.0f);
        mAnimator.setDuration(1500);
        mAnimator.setRepeatCount(ObjectAnimator.INFINITE);
        mAnimator.setRepeatMode(ObjectAnimator.REVERSE);
        mAnimator.start();
    } 
 
    @Override 
    protected void onDestroy() { 
        super.onDestroy(); 
        mAnimator.cancel();
    }