Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting which layout is loaded depending on the display size?

Tags:

android

I have an activity that has two layouts one in the folder layout and the other one in layout-large, (one is for the phone factor and the other one for the tablet form). How do I detect which layout is being loaded since in the tablet form I display more data?

Thanks

EDIT: I know that in the tablet it will load the layout-large but how do I know that I am running in something with a tablet form factor?

like image 847
Totic Avatar asked Mar 28 '11 08:03

Totic


1 Answers

You can detect it programmatically:

(getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;

and with other methods and properties in getResources().getConfiguration()

like image 197
Murat Avatar answered Oct 15 '22 11:10

Murat