简体   繁体   中英

Image proportions in android studio

Working in android studio. I'm importing an image into an imageview but as I test my app across different devices the images becomes a bit distored. I'm assuming this is because of different resolution/size of the devices. Is there anyway to maintain the same image size across all of the different android devices? Thank you.

First of all your image size must be larger than you're trying to support device(s). If your image is in app resources, you can resize it for hdpi, mdpi, xhdpi, xxhdpi, etc. and if the range is not suitable for the screen(s), you can crop in center or something like that. But if you get this image from a URL, you had better do this with Retrofit that does caching and background task.

Set to your ImageView android:scaleType="centerCrop" . That should solve your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM