Assume I have an activity with three different layouts in different resource folders. For example:
layout-land/my_act.xml
lay
You can get info about screen orientation and size from Resources
object. From there you can understand which layout is used.
getResources().getConfiguration().orientation;
- returns either Configuration.ORIENTATION_PORTRAIT
or Configuration.ORIENTATION_LANDSCAPE
.
int size = getResources().getConfiguration().screenLayout;
- returns mask of screen size. You can test against Small, Normal, Large, xLarge sizes. For example:
if ((size & Configuration.SCREENLAYOUT_SIZE_XLARGE)==Configuration.SCREENLAYOUT_SIZE_XLARGE)