How do I target the resolution of 1280x720 WXGA720 (for example, the new Galaxy Nexus) in Android Layout folders?

When testing my application with WXGA720 resolution on an Android emulator running 4.0.3 Ice Cream Sandwich, my application takes layout assets from the layout-normal-land-854x480 folder in landscape view and the layout-port-480x320 folder for portrait. I would like to be able to specifically target this resolution so that the application displays correctly on new phones. How should I do it? I tried the following ...

layout normal earth xhdpi
layout normal port xhdpi
layout normal earth XLarge
layout normal earth large
layout normal earth 1280x720
layout-normal-port-1280x720 etc.

... and he still takes assets from the wrong folders described above.

My app is for Android 2.1 (which I assume is still the standard goal these days), so I can't, as far as I know, use the new layout qualifiers. This is mistake? Has anyone had the same problem and found a workaround?

I have the following folder configuration, and all other AVDs are displayed as expected:

Layout Layout
-Ground
Layout Normal Ground 480x320
Layout Normal Ground 854x480
Layout Port 480x320
Layout Port 800x480

+5
source share
3 answers

WGXA720 Android-, 4.0.3 Ice Cream Sandwich, layout-normal-land-854x480 layout-port-480x320 .

, <supports-screens> (, , android:minSdkVersion) , .

, -480x320 -854x480. - . , , .

Android 2.1 (, , - ), , , .

. , -normal -land kin , . , .

+5

, , HTC Rezound 1280 720 . Android 2.3.4. , - . .

(layout-xhdpi, layout-large, layout-1280x720, layout-1200x700 ..) , , . http://developer.android.com/guide/practices/screens_support.html , . , , , , ! "uses-sdk" AndroidManifest.xml. :

<uses-sdk minSdkVersion="8"/>

sdk, Rezound. AndroidManifest.xml( ) :

<uses-sdk android:targetSdkVersion="9" minSdkVersion="8" />

, ? ! Android, , , . - , uses-sdk ?

+1

, ( ), . HTC Rezound, 1280 720. , Android , . onCreate:

// 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 magazines 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 calls this the regular display, so I created a res / layout-normal-1280x720 directory with my alternative 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 alternative layout to be used with this phone.

+1
source

All Articles