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 programmatically with this or this since this phone uses Android 2.2 and those solutions are for Android 3.2 and upwards. How can I create a new layout for this phone below Android 3.2?
Asked
Active
Viewed 1,674 times
0
-
Most of the techniques outlined in the second link work from Android 1.5 onwards. Certainly, resource set suffixes like `-hdpi` work from Android 1.5 onwards. – CommonsWare Aug 13 '12 at 11:53
-
@CommonsWare The problem is that I tried with 'layout-mdpi' for the Galaxy Ace and it never got the layout there, it simply used the default one -and Galaxy Ace is 320×480. – noloman Aug 13 '12 at 11:55
-
You normally do not use densities with layouts, but rather screen sizes. The Galaxy Ace should be a normal screen size device. – CommonsWare Aug 13 '12 at 12:14
2 Answers
2
Have you tried this:
DisplayMetrics displayMetrics = new DisplayMetrics();
((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(
displayMetrics);
switch (displayMetrics.densityDpi) {
case DisplayMetrics.DENSITY_HIGH:
...
}

ViliusK
- 11,345
- 4
- 67
- 71
0
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.

noloman
- 11,411
- 20
- 82
- 129