本文整理汇总了Java中android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT属性的典型用法代码示例。如果您正苦于以下问题:Java ActivityInfo.SCREEN_ORIENTATION_PORTRAIT属性的具体用法?Java ActivityInfo.SCREEN_ORIENTATION_PORTRAIT怎么用?Java ActivityInfo.SCREEN_ORIENTATION_PORTRAIT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.content.pm.ActivityInfo
的用法示例。
在下文中一共展示了ActivityInfo.SCREEN_ORIENTATION_PORTRAIT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setRequestedOrientation
@Override
public void setRequestedOrientation(int requestedOrientation) {
super.setRequestedOrientation(requestedOrientation);
if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
if (verticalControll != null) {
isVertical = true;
verticalControll.onCreate();
horizontalControll.onDestroy();
}
} else {
if (horizontalControll != null) {
isVertical = false;
horizontalControll.onCreate();
verticalControll.onDestroy();
}
}
}
示例2: getCurrentOrientation
private int getCurrentOrientation() {
int rotation = getWindowManager().getDefaultDisplay().getRotation();
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
switch (rotation) {
case Surface.ROTATION_0:
case Surface.ROTATION_90:
return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
default:
return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
}
} else {
switch (rotation) {
case Surface.ROTATION_0:
case Surface.ROTATION_270:
return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
default:
return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
}
}
}
示例3: lockOrientation
public static void lockOrientation(@NonNull AppCompatActivity appCompatActivity) {
int orientation;
switch (getRotationState(appCompatActivity)) {
case PORTRAIT:
orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
break;
case LANDSCAPE:
orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
break;
case REVERSE_PORTRAIT:
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
break;
case REVERSE_LANDSCAPE:
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
break;
default:
orientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
}
appCompatActivity.setRequestedOrientation(orientation);
}
示例4: onConfigurationChanged
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if(newConfig.orientation== ActivityInfo.SCREEN_ORIENTATION_PORTRAIT){
isFullScreen = false;
mRenderContainer.setVisibility(View.GONE);
mRenderContainer.removeAllViews();
}else{
isFullScreen = true;
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mRenderContainer.getLayoutParams();
layoutParams.topMargin = 0;
layoutParams.width = -1;
layoutParams.height = -1;
mRenderContainer.setLayoutParams(layoutParams);
}
}
示例5: onResume
@Override
protected void onResume() {
super.onResume();
lifecycleSubject.onNext(ActivityEvent.RESUME);
if (isRequestPermissionOnResume()) {
checkPermission();
} else {
if (!isFirstResume) {
checkPermission();
} else {
isFirstResume = false;
}
}
if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
}
示例6: onHideCustomView
@Override
public void onHideCustomView() {
LogUtils.i("Info", "onHideCustomView:" + moiveView);
if (moiveView == null)
return;
if (mActivity!=null&&mActivity.getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
moiveView.setVisibility(View.GONE);
if (moiveParentView != null && moiveView != null) {
moiveParentView.removeView(moiveView);
}
if (moiveParentView != null)
moiveParentView.setVisibility(View.GONE);
if(this.mCallback!=null)
mCallback.onCustomViewHidden();
this.moiveView = null;
if (mWebView != null)
mWebView.setVisibility(View.VISIBLE);
}
示例7: toggleScreen
public void toggleScreen(){
mOrEventListener.disable();
mOrEventListener1.enable();
int orientation = 0 ;
if(mOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT){
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
}else if(mOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE){
orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
}else if(mOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE){
orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
}else if(mOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT){
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
}
mOrientation = orientation;
mActivity.setRequestedOrientation(mOrientation);
}
示例8: onSensorChanged
@Override
public void onSensorChanged(SensorEvent event) {
try {
if (event.sensor == mRotationSensor && getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
if (event.values.length > 4) {
float[] truncatedRotationVector = new float[4];
System.arraycopy(event.values, 0, truncatedRotationVector, 0, 4);
update(truncatedRotationVector);
} else {
update(event.values);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例9: onConfigurationChanged
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
//portrait
} else {
isLandscape = true;
//landscape
}
}
示例10: unspecified
/**
* The requested screen orientation. Commonly used values are
unspecified (-1), landscape (0), portrait (1), sensor (4), and user (2). " +
"See the Android developer documentation for ActivityInfo.Screen_Orientation for the " +
"complete list of possible settings.
*
* ScreenOrientation property getter method.
*
* @return screen orientation
*/
@SimpleProperty(category = PropertyCategory.APPEARANCE,
description = "The requested screen orientation, specified as a text value. " +
"Commonly used values are " +
"landscape, portrait, sensor, user and unspecified. " +
"See the Android developer documentation for ActivityInfo.Screen_Orientation for the " +
"complete list of possible settings.")
public String ScreenOrientation() {
switch (getRequestedOrientation()) {
case ActivityInfo.SCREEN_ORIENTATION_BEHIND:
return "behind";
case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:
return "landscape";
case ActivityInfo.SCREEN_ORIENTATION_NOSENSOR:
return "nosensor";
case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
return "portrait";
case ActivityInfo.SCREEN_ORIENTATION_SENSOR:
return "sensor";
case ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED:
return "unspecified";
case ActivityInfo.SCREEN_ORIENTATION_USER:
return "user";
case 10: // ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR
return "fullSensor";
case 8: // ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
return "reverseLandscape";
case 9: // ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT
return "reversePortrait";
case 6: // ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
return "sensorLandscape";
case 7: // ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
return "sensorPortrait";
}
return "unspecified";
}
示例11: mapConfigurationOriActivityInfoOri
private int mapConfigurationOriActivityInfoOri(int configOri) {
final Display d = getWindowManager().getDefaultDisplay();
int naturalOri = Configuration.ORIENTATION_LANDSCAPE;
switch (d.getRotation()) {
case Surface.ROTATION_0:
case Surface.ROTATION_180:
// We are currently in the same basic orientation as the natural orientation
naturalOri = configOri;
break;
case Surface.ROTATION_90:
case Surface.ROTATION_270:
// We are currently in the other basic orientation to the natural orientation
naturalOri = (configOri == Configuration.ORIENTATION_LANDSCAPE) ?
Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE;
break;
}
int[] oriMap = {
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT,
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE,
ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT,
ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
};
// Since the map starts at portrait, we need to offset if this device's natural orientation
// is landscape.
int indexOffset = 0;
if (naturalOri == Configuration.ORIENTATION_LANDSCAPE) {
indexOffset = 1;
}
return oriMap[(d.getRotation() + indexOffset) % 4];
}
示例12: getCurrentOrientation
private int getCurrentOrientation() {
int rotation = getWindowManager().getDefaultDisplay().getRotation();
switch (rotation) {
case Surface.ROTATION_0:
case Surface.ROTATION_90:
return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
default:
return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
}
}
示例13: getScreenOrientation
private int getScreenOrientation() {
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
DisplayMetrics dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
int width = dm.widthPixels;
int height = dm.heightPixels;
int orientation;
// if the device's natural orientation is portrait:
if ((rotation == Surface.ROTATION_0
|| rotation == Surface.ROTATION_180) && height > width ||
(rotation == Surface.ROTATION_90
|| rotation == Surface.ROTATION_270) && width > height) {
switch (rotation) {
case Surface.ROTATION_0:
orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
break;
case Surface.ROTATION_90:
orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
break;
case Surface.ROTATION_180:
orientation =
ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
break;
case Surface.ROTATION_270:
orientation =
ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
break;
default:
orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
break;
}
}
// if the device's natural orientation is landscape or if the device
// is square:
else {
switch (rotation) {
case Surface.ROTATION_0:
orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
break;
case Surface.ROTATION_90:
orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
break;
case Surface.ROTATION_180:
orientation =
ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
break;
case Surface.ROTATION_270:
orientation =
ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
break;
default:
orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
break;
}
}
return orientation;
}
示例14: getScreenOrientation
@RequiresApi(api = Build.VERSION_CODES.FROYO)
private int getScreenOrientation() {
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
DisplayMetrics dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
int width = dm.widthPixels;
int height = dm.heightPixels;
int orientation;
// if the device's natural orientation is portrait:
if ((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && height > width ||
(rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && width > height) {
switch (rotation) {
case Surface.ROTATION_0:
orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
break;
case Surface.ROTATION_90:
orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
break;
case Surface.ROTATION_180:
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
break;
case Surface.ROTATION_270:
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
break;
default:
orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
break;
}
}
// if the device's natural orientation is landscape or if the device
// is square:
else {
switch (rotation) {
case Surface.ROTATION_0:
orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
break;
case Surface.ROTATION_90:
orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
break;
case Surface.ROTATION_180:
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
break;
case Surface.ROTATION_270:
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
break;
default:
orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
break;
}
}
return orientation;
}
示例15: orientationPortrait
public static ViewAction orientationPortrait() {
return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}