How to define an Android or galaxy tab?

I am creating an Android application that supports both the Android mobile phone and the galaxy tab, I need to dynamically align the text, this is the mobile version (small layout) I need to configure the text for the text view dynamically as "mobile phone", otherwise, if it is a tab galaxy galaxy or some other Android tab, I need to dynamically set the text as “Galaxy Tab”.

If anyone knows a solution will help me?

Thank.

+3
source share
3 answers

You can use this function to dynamically determine the width of a device:

int screenWidth=getWindowManager().getDefaultDisplay().getWidth();

a > 480, , Android. , .

0

- :

int mask = Configuration.SCREENLAYOUT_SIZE_MASK;
int size = context.getResources().getConfiguration().screenLayout;
if ((size & mask) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
    // Screen is classified x-large
}

, Configuration.

+3

Build.Model , .

( , DisplayMetrics, /, , , .)

+1

All Articles