I had answered this question before but my previous response only allowed me to fill the display (it only filled the top third before) but I could never get an alternate layout to be used.
I am using an HTC Rezound which has a 1280 by 720 display. I needed to find out what kind of display Android thinks that it is. I added the following code in my onCreate handler:
// Figure out what kind of display we have
int screenLayout = getResources().getConfiguration().screenLayout;
if ((screenLayout & Configuration.SCREENLAYOUT_SIZE_SMALL) == Configuration.SCREENLAYOUT_SIZE_SMALL)
LogMessage("Main onCreate", "Info", "Screen size is Small");
else if ((screenLayout & Configuration.SCREENLAYOUT_SIZE_NORMAL) == Configuration.SCREENLAYOUT_SIZE_NORMAL)
LogMessage("Main onCreate", "Info", "Screen size is Normal");
else if ((screenLayout & Configuration.SCREENLAYOUT_SIZE_LARGE) == Configuration.SCREENLAYOUT_SIZE_LARGE)
LogMessage("Main onCreate", "Info", "Screen size is Large");
if ((screenLayout & Configuration.SCREENLAYOUT_LONG_YES) == Configuration.SCREENLAYOUT_LONG_YES)
LogMessage("Main onCreate", "Info", "Screen size is Long");
// Get the metrics
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int heightPixels = metrics.heightPixels;
int widthPixels = metrics.widthPixels;
int densityDpi = metrics.densityDpi;
float density = metrics.density;
float scaledDensity = metrics.scaledDensity;
float xdpi = metrics.xdpi;
float ydpi = metrics.ydpi;
LogMessage("Main onCreate", "Info", "Screen W x H pixels: " + widthPixels + " x " + heightPixels);
LogMessage("Main onCreate", "Info", "Screen X x Y dpi: " + xdpi + " x " + ydpi);
LogMessage("Main onCreate", "Info", "density = " + density + " scaledDensity = " + scaledDensity +
" densityDpi = " + densityDpi);
And the results in the logs were:
Info, Main onCreate, Screen size is Normal
Info, Main onCreate, Screen size is Long
Info, Main onCreate, Screen W x H pixels: 720 x 1280
Info, Main onCreate, Screen X x Y dpi: 345.0566 x 342.23157
Info, Main onCreate, density = 2.0 scaledDensity = 2.0 densityDpi = 320
With this I realized that Android was calling this a normal display so I created a res / layout-normal-1280x720 directory with my alternate layout files.
My manifest contained:
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"
/>
<uses-sdk android:targetSdkVersion="9" android:minSdkVersion="8" />
With these changes I was finally able to get an alternate layout to be used with this phone.