简体   繁体   中英

Why dp, px, mm looks different in different android phones

Every time when I have to set width, height, margin, padding, etc of widget or layout i think which unit would looks same in all android phones. I have tried all these units in my different apps. But there are many devices where your 5dp seems 10dp or more. I have read many articles, blogs and stackoverflow posts about screen densities that describes all phones have different screen densities thats why dp looks different in different phones. But mm and cm are physical units. So they should be look same in different phones. But they also not working like physical units. So my question is there any way that we can use these units or any new that look same in all mobile phones?

There are different reasons, one been the quantity of pixels within a particular screen referred as dpi (dots per inch). "low" density screens have fewer pixels within a given physical area, compared to a "normal" or "high" density screen.

It also has to do whit orientation, either landscape or portrait, meaning that the screen's aspect ratio is either wide or tall.

You can get more insight on the matter here: Official documentation

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