Multiple screen support for my app?

可紊 提交于 2019-12-13 19:54:43

问题


I am quite confused whether I have to deal with my device, which I'm currently testing my app on, as a medium or large density device. The device is Samsung Galaxy S3 mini with 480 x 800 pixels, 4.0 inches display according to the device specifications provided by Samsung.

I am planning to optimize my drawables such that a wide range of screen sizes and densities are supported. Since S3 mini is my testing device, which launcher icon is actually the one used in it? is it the one under drawable-ldpi, drawable-mdpi, drawable-hdpi or drawable-xhdpi?


回答1:


Try this way,hope this will help you to solve your problem.

switch (getResources().getDisplayMetrics().densityDpi) {
    case DisplayMetrics.DENSITY_LOW:
         // write your code here.
         break;
    case DisplayMetrics.DENSITY_MEDIUM:
         // write your code here.
         break;
    case DisplayMetrics.DENSITY_HIGH:
         // write your code here.
         break;
    case DisplayMetrics.DENSITY_XHIGH:
         // write your code here.
         break;
    case DisplayMetrics.DENSITY_XXHIGH:
         // write your code here.
         break;
    case DisplayMetrics.DENSITY_TV:
         // write your code here.
         break;
 }



回答2:


I checked my device's used drawable by detecting the width of the launcher icon as follows:

BitmapDrawable bd=(BitmapDrawable) this.getResources().getDrawable(R.drawable.ic_launcher);
Log.i("moayad", ""+ bd.getBitmap().getWidth());

The reported width is 72 which is the width of the icon placed in the drawable-hdpi folder. Hence, my phone is categorized under the high density folder.



来源:https://stackoverflow.com/questions/24709630/multiple-screen-support-for-my-app

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