Code example for Drawable

Methods: drawgetIntrinsicHeightgetIntrinsicWidthsetAlpha

0
    public float getPositionY() { 
        return mPositionY;
    } 
 
    public int getWidth() { 
        return mDrawable != null ? mDrawable.getIntrinsicWidth() : 0;
    } 
 
    public int getHeight() { 
        return mDrawable != null ? mDrawable.getIntrinsicHeight() : 0;
    } 
 
    public void draw(Canvas canvas) {
        if (mDrawable == null || !mEnabled) {
            return; 
        } 
        canvas.save(Canvas.MATRIX_SAVE_FLAG);
        canvas.scale(mScaleX, mScaleY, mPositionX, mPositionY);
        canvas.translate(mTranslationX + mPositionX, mTranslationY + mPositionY);
        canvas.translate(-0.5f * getWidth(), -0.5f * getHeight());
        mDrawable.setAlpha((int) Math.round(mAlpha * 255f));
        mDrawable.draw(canvas);
        canvas.restore();
    } 
 
    public void setEnabled(boolean enabled) {
        mEnabled  = enabled;