开发者

Android ImageView and Bitmap on canvas don't have the same size

I have a Bitmap image in my ressources.

When i draw it using an ImageView, it doesn't have the same size as when I draw it on the canvas using Drawbitmap. No matter what density I use to my bitmap ( 160, 240 ), the bitmap is always zoomed. How to draw the bitmap so it has the same size as when I use an image开发者_JAVA百科view ?


The trick is to create a scaled bitmap and then draw.

my_bitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.my_bitmap);
my_bitmap = Bitmap.createScaledBitmap(my_bitmap, screenWidth, screenHeight, true);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜