I'm displaying an image through an ImageSwitcher with this factory:
view_background.setFactory {
val imageView = ImageView(this@MainActivity)
imageView.scaleType = ImageView.ScaleType.CENTER_CROP
imageView
}
And I'm displaying correctly this 2341x1246 PNG
2.55 MB image on a Nexus 5 emulator:
However, if I use it on Nexus 6, it crashes:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.llovagn.t4r, PID: 4693
java.lang.RuntimeException: Canvas: trying to draw too large(142936136bytes) bitmap.
By putting it in drawable-xxhdpi
as suggested in this answer, it now look like this on both devices:
Which I something that I don't really want (the first way is the correct one). Why and how can I solve this?