Skip to content

Instantly share code, notes, and snippets.

@OwloneDev
Last active August 9, 2020 17:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OwloneDev/899c1a158a677cbb8e5ab2c86d0e72a3 to your computer and use it in GitHub Desktop.
Save OwloneDev/899c1a158a677cbb8e5ab2c86d0e72a3 to your computer and use it in GitHub Desktop.
private fun imageScaling(imageResource: Int): BitmapDrawable {
val options = BitmapFactory.Options()
options.inScaled = false
val bitmap = BitmapFactory.decodeResource(context.resources, imageResource, options)
val bitmapDrawable = BitmapDrawable(context.resources, bitmap)
bitmapDrawable.isFilterBitmap = false
return bitmapDrawable
}
imageView.setImageDrawable(imageScaling(R.drawable.myImage))
imageView2.background = imageScaling(R.drawable.myImage)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment