Code example for Drawable

Methods: isStatefulsetState

0
    protected void drawableStateChanged() { 
        super.drawableStateChanged(); 
 
        // Update the state of the highlight drawable to match 
        // the state of the button. 
        if (mForegroundDrawable.isStateful()) {
            mForegroundDrawable.setState(getDrawableState());
        } 
 
        // Trigger a redraw. 
        invalidate();
    } 
 
    @Override 
    protected void onDraw(Canvas canvas) {
        // First draw the image. 
        super.onDraw(canvas);
 
        // Then draw the highlight on top of it. If the button is neither focused 
        // nor pressed, the drawable will be transparent, so just the image 
        // will be drawn.