Android - Screen Resolution and Screen Density

白昼怎懂夜的黑 提交于 2019-12-05 13:55:06

There are specific Android API calls that can, at runtime tell you what density and (small/large/normal) screen size a handset has. However, as a developer we should not need to worry about individual handsets at all. All we need to do is to have ldpi/mdpi/hdpi assets and small/normal/large layouts in the apk. Android internally handles everything.

Dont forget to get an indepth understanding of how Android determines which assets to use and aliasing here.

Why do you want to know the actual density? It's Android's business. But I'm sure there is a way to retrieve this information.

For development I put everything in the hdpi-folder. I also could put everything in a general Drawable Folder.

At the time u publish u can decide if u want to provide already downscaled resources for ldpi and mdpi. However, thats not necessary.

Update: Retrieve actual density with this class and best practices

Update 2: I found a 25 min video from Motorola discussing all those issues: Working with multiple screens

Hardik4560

1) Change the content of the layout in different folders i.e layout-small, layout-large, etc Now test it in Different emulator with different screen resolution.

2) For Finding out density of the Device use
Log.d("Density", "" + (getResources().getDisplayMetrics().density));

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!