Android - Screen Resolution and Screen Density

吃可爱长大的小学妹 提交于 2019-12-10 09:21:58

问题


As per managing resources(images) in > Android 1.6 version, we need to keep different-resolutions image in Drawable-Hdpi, Drawable-Mdpi, Drawable-Lpi folder particularly.

And as per this page: http://developer.android.com/guide/practices/screens_support.html ,

In Low density section - there are three resolutions used: 240*320 , 240x400 , 240x432 for the Small screen, Normal Screen, Large Screen particularly.

same way for Medium density section - there are three resolutions used: 320x480 , 480x800 , 480x854 for the Small screen, Normal Screen, Large Screen particularly.

and same way for High density ........

but i am confused here:

(1) How do i come to know that whether small, Normal or Large screen is used, i mean is there any way to know ?

(2) How do i come to know which type of density i am using ?

(3) And in Drawable-Hdpi, Drawable-Mdpi, Drawable-ldpi folder, which resolution's image we should keep particularly?

pls share your knowledge.


回答1:


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.




回答2:


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




回答3:


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));



来源:https://stackoverflow.com/questions/3804548/android-screen-resolution-and-screen-density

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