Android ImageView Fixing Image Size

后端 未结 4 1260
梦如初夏
梦如初夏 2021-01-30 12:44

I have an Android Application, where I have an ImageView, I need to keep the size constant, there can be various images that I need to put into this ImageView

4条回答
  •  说谎
    说谎 (楼主)
    2021-01-30 13:37

    Try this

    ImageView img
        Bitmap bmp;
        int width=100;
        int height=100;
        img=(ImageView)findViewById(R.id.imgView);
        bmp=BitmapFactory.decodeResource(getResources(),R.drawable.image);//image is your image                                                            
        bmp=Bitmap.createScaledBitmap(bmp, width,height, true);
        img.setImageBitmap(bmp);
    

    Or If you want to load complete image size in memory then you can use

    
    

提交回复
热议问题