just_user
just_user

Reputation: 12067

Android set a specific layout for a specific device

I'm currently developing an app that as usual has to run on multiple devices but there is one more special than the others. An Acer DA241HL which is a 24" "Tablet" with a 1920x1080px resolution that should be wall mounted somewhere.

Is there a good way to identify this screen. Right now it reacts to the values-sw600dp folder. But what ever changes I make for this enormous tablet shouldn't affect normal tablet which would happen if I change stuff in that folder.

The following code:

    DisplayMetrics metrics = getResources().getDisplayMetrics();
    float density  = getResources().getDisplayMetrics().density;
    float dpHeight = metrics.heightPixels / density;
    float dpWidth  = metrics.widthPixels / density;
    Log.e("screen", "******************************************************");
    Log.w("screen", "d " + density + " y" + dpHeight + " x" + dpWidth + " deviceType:" + getResources().getString(R.string.device_type));
    Log.e("screen", "******************************************************");

Print the following:

******************************************************
d 1.0 y1032.0 x1920.0 deviceType:5
******************************************************

But I dont see how I can make that useful. The other way I thought about is to get the model number of the device but that creates new problem if they decide to get a similar device but not the same.

Suggestions?

Upvotes: 0

Views: 497

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007554

Is there a good way to identify this screen

Use something like -swNNNdp, for a suitably high value of NNN.

Right now it reacts to the values-sw600dp folder

Well, sure, but that screen is far larger than 600dp in its smallest width.

But what ever changes I make for this enormous tablet shouldn't affect normal tablet which would happen if I change stuff in that folder.

Then add a res/values-sw1000dp/ directory, for resources to use for screens with 1000dp in the smallest width, which will include your Acer but will not include more normal-sized tablets.

Upvotes: 1

Related Questions