Create a file from drawable

后端 未结 4 1318
滥情空心
滥情空心 2020-12-30 07:04

I have a large number of resources in my drawable folder.All are having big size more than 500KB. I have to load all these 25 images all at once in a srollView. As usual I r

4条回答
  •  清歌不尽
    2020-12-30 07:27

    I like shortcuts so I prefer using this.

    For creatting file from drawable see this.

    Put this in your build.gradle

    compile 'id.zelory:compressor:1.0.4'
    

    And wherever you want to compress the image put

     Bitmap compressedImageFile = Compressor.getDefault(context).compressToBitmap(your_file);
    

    README.md provides much more information. Sorry for bringing the answer after 6 years.

提交回复
热议问题