My understanding is that if you use a View
object (as supposed to eg. android:windowBackground
) Android will automatically scale your image to the correct size. The problem is that too much scaling can result in artifacts (both during up and down scaling) and blurring. Due to various resolutions and aspects ratios on the market, it's impossible to create "perfect" fits for every screen, but you can do your best to make sure only a little bit of scaling has to be done, and thus mitigate the unwanted side effects. So what I would do is:
getDisplayMetrics().density
returns 4 (xxxhdpi), so perhaps this info is outdated.Then look at the new phone models on the market, and find the representative ones. Assumming the new google pixel is a good representation of an android phone: It has a 1080 x 1920 resolution at 441 dpi, and a screen size of 4.4 x 2.5 inches. Then from the the android developer docs:
- ldpi (low) ~120dpi
- mdpi (medium) ~160dpi
- hdpi (high) ~240dpi
- xhdpi (extra-high) ~320dpi
- xxhdpi (extra-extra-high) ~480dpi
- xxxhdpi (extra-extra-extra-high) ~640dpi
This corresponds to an xxhdpi
screen. From here I could scale these 1080 x 1920 down by the (3:4:6:8:12) ratios above.
sw
, long
, large
, etc.<item name="android:windowBackground">@null</item>