List of usage examples for android.content.res Configuration ORIENTATION_PORTRAIT
int ORIENTATION_PORTRAIT
To view the source code for android.content.res Configuration ORIENTATION_PORTRAIT.
Click Source Link
From source file:Main.java
public static int convertConfigToTiOrientationMode(int configOrientationMode) { switch (configOrientationMode) { case Configuration.ORIENTATION_PORTRAIT: return ORIENTATION_PORTRAIT; case Configuration.ORIENTATION_LANDSCAPE: return ORIENTATION_LANDSCAPE; case Configuration.ORIENTATION_SQUARE: return ORIENTATION_SQUARE; default:/*w ww . j a va 2s. co m*/ return ORIENTATION_UNKNOWN; } }
From source file:Main.java
/** * Get the span count for a gridlayoutmanager for example. returns how many columns the * list of items should contain./*from w w w. j a va 2 s . c om*/ * @param activity * @return The amount of columns the screen can fit */ public static int getSpanCount(Activity activity) { double diagonalInches = getDisplayInches(activity); int orientation = getDisplayOrientation(activity); if (diagonalInches >= 10) { if (orientation == Configuration.ORIENTATION_PORTRAIT) { return 3; } else { return 4; } } else if (diagonalInches >= 7) { if (orientation == Configuration.ORIENTATION_PORTRAIT) { return 2; } else { return 3; } } else { if (orientation == Configuration.ORIENTATION_PORTRAIT) { return 1; } else { return 1; } } }
From source file:Main.java
public static int getOrientation(Context context) { WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display getOrient = windowManager.getDefaultDisplay(); int orientation = Configuration.ORIENTATION_UNDEFINED; if (getOrient.getWidth() == getOrient.getHeight()) { orientation = Configuration.ORIENTATION_SQUARE; } else {//from ww w . j a va 2 s . co m if (getOrient.getWidth() < getOrient.getHeight()) { orientation = Configuration.ORIENTATION_PORTRAIT; } else { orientation = Configuration.ORIENTATION_LANDSCAPE; } } return orientation; }
From source file:Main.java
public static final boolean isPortrait(Context context) { return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; }
From source file:Main.java
public static boolean screenIsPortrait(Context context) { return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; }
From source file:Main.java
public static int getNavigationBarHeight(Context c) { int result = 0; boolean hasMenuKey = ViewConfiguration.get(c).hasPermanentMenuKey(); boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); if (!hasMenuKey && !hasBackKey) { //The device has a navigation bar Resources resources = c.getResources(); int orientation = resources.getConfiguration().orientation; int resourceId; if (isTablet(c)) { resourceId = resources// w w w . ja v a 2 s.co m .getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android"); } else { resourceId = resources .getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_width", "dimen", "android"); } if (resourceId > 0) { return resources.getDimensionPixelSize(resourceId); } } return result; }
From source file:Main.java
/** * is portrait//w w w . j a va 2s. c o m * * @param context * @return */ public static boolean isPortrait(Context context) { return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; }
From source file:Main.java
public static void lockOrientation(Activity activity) { Display display = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int rotation = display.getRotation(); int tempOrientation = activity.getResources().getConfiguration().orientation; int orientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; switch (tempOrientation) { case Configuration.ORIENTATION_LANDSCAPE: if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; else// w w w . ja v a2 s. c o m orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; break; case Configuration.ORIENTATION_PORTRAIT: if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_270) orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; else orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; } activity.setRequestedOrientation(orientation); }
From source file:Main.java
public static boolean isOriatationPortrait(Context context) { return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; }
From source file:Main.java
public static void rotateOrientation(Activity activity) { int currentOrientation = activity.getResources().getConfiguration().orientation; switch (currentOrientation) { case Configuration.ORIENTATION_LANDSCAPE: rotateToPortrait(activity);/* ww w .j a v a 2 s. c om*/ break; case Configuration.ORIENTATION_PORTRAIT: rotateToLandscape(activity); break; default: rotateToLandscape(activity); } }