Reputation: 763
Scenario
I am developing a random app and recently i encountered a problem. I run a same application on Google pixel 3a xl android emulator and Asus X00TD physical device. And I got to know that in asus phone UI got really changed.
Pixel 3a XL display specs :
Display size : 6.0 inch Resolution : 2160 × 1080 ppi : 402ppi
Asus X00TD display specs :
Display size : 6.0 inch Resolution : 2160 × 1080 ppi : 403ppi
You see It's almost same only ppi is different and i don't think so that will make some big difference. roughly 6 pixels will be affected and that's not gonna change whole UI. I don't know the dpi
resolution of the asus x00td. And I can't find on internet too.
This is the UI difference between pixel 3a xl and asus x00td.
As you can see there's big difference between emulator and physical phone. So, I have 2 questions
There's a way to calculate dpi by function. but, What if I don't have a phone and still want to know dpi res of that phone?
Why there is a big difference between emulator and physical phone?
EDIT
I tried to calculate it on internet but, it gave me 0.0631mm
dot pitch. which i am not able to understant what it is. Also emulator shows that pixel 3a xl has 400dpi
resolution.
So, What is difference between 400dpi
and 0.0631mm dot pitch
?
SOLUTION I TRIED
I tried to emulate the asus device in emulator by setting smallest width to 360dp. Initially it looked same as asus. and emulator was picking xhdpi
file of dimens.xml
. So, I made changes in dimens.xml
of xhdpi
but, asus didn't pick that file. instead it picked xxhdpi
file. Which is used in another device Realme 3 pro. I can't modify xxhdpi
file because it's gonna mess up UI for all the 6+ inch display phones. and at the same time asus is still picking xxhdpi
file and asus's UI is messed up.
Can't find a solution to this.
Upvotes: 1
Views: 760
Reputation: 763
As explained upper by snachmsm, Layout qualifiers are most helpful in acheiving display responsiveness.
In my case it was the asus x00td which wasn't displaying the content correctly. SO, to fix that,
I used height
qualifier value ofheight
which resulted in minimum height.. So, devices with height of 600dp
or above will be using dimens.xml(h600dp)
. So, asus picked up this file. As well as I created file for 700dp
as well which has slighly bigger dimensions for large display like realme 3 pro.
Plus I used constraint layout guidelines percentages to rearrange views in manner that margins will be adjusted automatically.
So, dimensions and sizes are controlled by dimens.xml and margins are automatically controlled by constraint layout.
Upvotes: 0
Reputation: 19263
these differences are caused by different density bucket set for these devices by manufacturers. from doc:
xhdpi Resources for extra-high-density (xhdpi) screens (~320dpi).
xxhdpi Resources for extra-extra-high-density (xxhdpi) screens (~480dpi).
note that you are somewhere in the middle of these values. looks like Asus decided to configure own Android as xxhdpi
, so interface scales up to bigger UI elements (also uses bigger images), while Google set up xhdpi
qualifier making own interface "more packable" with smaller UI elements and icons
under density qualifiers you can keep e.g. dimen
, so size of margins or thickness of some lines or borders. Especially when you are using many resources with @android
/android.R
prefix, built into system - these are oftenly highly parametrized depending on bucket, e.g. thick list items separator may have 0
height value on ldpi
devices for hidding it out leaving more space for content on such small/poor screen. also different images/drawables are used to draw. put a red dot on icon in top right corner, but only in xxhdpi
folder and you will see that only one device will get this change
also there is an option in developer settings for manipulating "max width", in there you can "change density" and can try how interface of whole system and apps change. bet on Asus is set to ~360 when on Pixel is set to at least 400 (rounding up to xx bucket, as closer to 480)
Upvotes: 1