clickArea icon indicating copy to clipboard operation
clickArea copied to clipboard

点击的屏幕区域不对应图片区域

Open gzu-liyujiang opened this issue 12 years ago • 1 comments

        Drawable drawable = ((StateListDrawable)getBackground()).getCurrent();
        bitmap = ((BitmapDrawable)drawable).getBitmap();
以上代码好像有bug:在华为p6等高分辨率的手机上,点击的屏幕区域并不对应图片区域。可以通过把当view(而不是背景图)转化为bitmap来解决

gzu-liyujiang avatar Oct 10 '14 12:10 gzu-liyujiang

代码如下:

                width = getWidth();
                height = getHeight();
                setDrawingCacheEnabled(true);
                buildDrawingCache();
                Bitmap tempBitmap = getDrawingCache();
                bitmap = Bitmap.createBitmap(tempBitmap, 0, 0, width, height);
                destroyDrawingCache();

gzu-liyujiang avatar Oct 10 '14 12:10 gzu-liyujiang