I’m making an app and wanted an image to scale well with different-sized screens, but when I made the width and height match the parent, it ignored the margins, making the image go out of bounds in smaller devices and too small in larger ones. The fix I found is in the answers below:
Question posted in Android Studio
The official documentation can be found here.
The official documentation can be found here.
2
Answers
I like having my images rounded off, so I put them inside a CardView. It looks like this:
if you don't like your images rounded off, just skip the CardView:
You should add this into your imageView in xml file
if it doesn’t work, change "fitXY" to remain options of scaleType.