获得当前背景

 Drawable bg= getBackground();
        //bg包括color和Drawable
        if (bg instanceof ColorDrawable) {
            ColorDrawable colordDrawable = (ColorDrawable) bg;
            int color = colordDrawable.getColor();
            paint.setColor(color);
            setBackgroundDrawable(null);
        } else {
            bgBitmap = ((BitmapDrawable) bg).getBitmap();
            setBackgroundDrawable(null);
        }

猜你喜欢

转载自blog.csdn.net/weixin_37160260/article/details/79959769