开发者

how to display complete Bitmap in android using Canvas?

开发者 https://www.devze.com 2023-01-03 04:06 出处:网络
friends, i am using following onDraw method to display bitmap on screen. @Override public void onDraw(Canvas canvas) {

friends,

i am using following onDraw method to display bitmap on screen.

 @Override
            public void onDraw(Canvas canvas) {

                    Bitmap _scratch =  BitmapFactory.decodeResource(getResources(), R.drawable.icon2);

                    //ImageView img= new ImageView(Tutorial2D.this);
                    //img.setImageBitmap(_scratch);
                    canvas.drawColor(Color开发者_Go百科.BLACK);

                    canvas.drawBitmap(_scratch, 0, 0, null);


            }

image is displayed on the screen but some part because android screen is small how can i display complete image in whole android screen?

can i set ScaleType of image to fitxy in canvas ?

or

can i add android layout image to this canvas so that i could set fitxy property or image there as i have commented the code?

any help would be appreciated.


You can call Bitmap.createScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter)


You can use a ImageView

iv = (ImageView) findViewById(R.id.ImageView01);
iv.setImageBitmap(getImageBitmap(myurl));
0

精彩评论

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