Skip to content Skip to sidebar Skip to footer

Detecting Screen Density Programmatically, Pre-honeycomb

I have a layout that works in certain phones, but in the Samsung Galaxy Ace doesn't work properly. I need to create a new layout for this phone (and similar) but I can't do it prog

Solution 1:

Have you tried this:

DisplayMetricsdisplayMetrics=newDisplayMetrics();
    ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(
            displayMetrics);

    switch (displayMetrics.densityDpi) {
        case DisplayMetrics.DENSITY_HIGH: 
     ...
    }

Solution 2:

What I did in the end, was creating a folder called 'layout-sw320dp' which the Galaxy Nexus will take -while the Galaxy Ace will use the layout in the normal 'layout' folder- and I did the pertinent modifications for each phone/layout.

Post a Comment for "Detecting Screen Density Programmatically, Pre-honeycomb"