List of usage examples for android.content.res Configuration ORIENTATION_SQUARE
int ORIENTATION_SQUARE
To view the source code for android.content.res Configuration ORIENTATION_SQUARE.
Click Source Link
From source file:Main.java
public static int getScreenOrientation(Activity activity) { Display getOrient = activity.getWindowManager().getDefaultDisplay(); int orientation = Configuration.ORIENTATION_UNDEFINED; if (getOrient.getWidth() == getOrient.getHeight()) { orientation = Configuration.ORIENTATION_SQUARE; } else {/* w w w . j a v a2 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 String getDisplayOrientation(Context context) { String text;//from w w w . ja va 2s .com switch (context.getResources().getConfiguration().orientation) { case Configuration.ORIENTATION_PORTRAIT: text = "portrait"; break; case Configuration.ORIENTATION_LANDSCAPE: text = "landscape"; break; case Configuration.ORIENTATION_SQUARE: text = "square"; break; default: text = null; } ; return text; }
From source file:Main.java
public static int getScreenOrientation(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); int orientation = Configuration.ORIENTATION_UNDEFINED; if (display.getWidth() == display.getHeight()) { orientation = Configuration.ORIENTATION_SQUARE; } else {/* w ww .j ava2s. co m*/ if (display.getWidth() < display.getHeight()) { orientation = Configuration.ORIENTATION_PORTRAIT; } else { orientation = Configuration.ORIENTATION_LANDSCAPE; } } return orientation; }
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 {// w w w . jav a2 s . c o m if (getOrient.getWidth() < getOrient.getHeight()) { orientation = Configuration.ORIENTATION_PORTRAIT; } else { orientation = Configuration.ORIENTATION_LANDSCAPE; } } return orientation; }
From source file:Main.java
/** * Overall orientation of the screen.// w ww. ja va 2 s . c o m * @param orientation "orientation" */ @SuppressWarnings("deprecation") public static String getOrientationStr(int orientation) { switch (orientation) { case Configuration.ORIENTATION_UNDEFINED://0 return "ORIENTATION_UNDEFINED"; case Configuration.ORIENTATION_PORTRAIT://1 return "ORIENTATION_PORTRAIT"; case Configuration.ORIENTATION_LANDSCAPE://2 return "ORIENTATION_LANDSCAPE"; case Configuration.ORIENTATION_SQUARE://3 return "ORIENTATION_SQUARE"; default: return UNKNOWN; } }
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:/*from w ww. j a va2s . c o m*/ return ORIENTATION_UNKNOWN; } }
From source file:Main.java
public static int getScreenOrientation(Context context) { Display display = getDefaultDisplay(context); int orientation = Configuration.ORIENTATION_UNDEFINED; if (display.getWidth() == display.getHeight()) orientation = Configuration.ORIENTATION_SQUARE; else {// w w w.j a v a 2s . c om if (display.getWidth() < display.getHeight()) orientation = Configuration.ORIENTATION_PORTRAIT; else orientation = Configuration.ORIENTATION_LANDSCAPE; } return orientation; }
From source file:Main.java
public static int getSurfaceOrientation(Activity activity) { // Sanity check: if (activity == null) { return -1; // invalid value }//from ww w . j ava2 s . c o m Configuration config = activity.getResources().getConfiguration(); Display display = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int displayRotation; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { displayRotation = display.getRotation(); // only available from Froyo } else { displayRotation = display.getOrientation(); } int activityOrientation = SCREEN_ORIENTATION_UNKNOWN; switch (config.orientation) { case Configuration.ORIENTATION_PORTRAIT: case Configuration.ORIENTATION_SQUARE: activityOrientation = ((displayRotation == Surface.ROTATION_0 || displayRotation == Surface.ROTATION_270) ? SCREEN_ORIENTATION_PORTRAIT : SCREEN_ORIENTATION_PORTRAITUPSIDEDOWN); break; case Configuration.ORIENTATION_LANDSCAPE: activityOrientation = ((displayRotation == Surface.ROTATION_0 || displayRotation == Surface.ROTATION_90) ? SCREEN_ORIENTATION_LANDSCAPELEFT : SCREEN_ORIENTATION_LANDSCAPERIGHT); break; case Configuration.ORIENTATION_UNDEFINED: default: break; } return activityOrientation; }
From source file:com.simplaapliko.util.sample.MainFragment.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.get_screen_orientation: switch (Screen.getOrientation(getActivity())) { case Configuration.ORIENTATION_PORTRAIT: mMessage.setText(R.string.portrait); break; case Configuration.ORIENTATION_LANDSCAPE: mMessage.setText(R.string.landscape); break; case Configuration.ORIENTATION_SQUARE: mMessage.setText(R.string.square); break; }/*w w w . j a va 2 s . c o m*/ break; } }
From source file:com.manning.androidhacks.hack014.MainActivity.java
private void setVideoViewPosition() { switch (getResources().getConfiguration().orientation) { case Configuration.ORIENTATION_LANDSCAPE: { mPortraitContent.setVisibility(View.GONE); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); params.addRule(RelativeLayout.CENTER_IN_PARENT); mVideoView.setLayoutParams(params); break;//from w ww . ja va 2 s. c o m } case Configuration.ORIENTATION_SQUARE: case Configuration.ORIENTATION_UNDEFINED: case Configuration.ORIENTATION_PORTRAIT: default: { mPortraitContent.setVisibility(View.VISIBLE); int[] locationArray = new int[2]; mPortraitPosition.getLocationOnScreen(locationArray); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(mPortraitPosition.getWidth(), mPortraitPosition.getHeight()); params.leftMargin = locationArray[0]; params.topMargin = locationArray[1]; mVideoView.setLayoutParams(params); break; } } }