當前位置: 首頁>>代碼示例>>Java>>正文


Java ActivityInfo.SCREEN_ORIENTATION_PORTRAIT屬性代碼示例

本文整理匯總了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();
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:TvShowActivity.java

示例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;
        }
    }
}
 
開發者ID:xiong-it,項目名稱:ZXingAndroidExt,代碼行數:20,代碼來源:QrCodeScannerActivity.java

示例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);
}
 
開發者ID:GrenderG,項目名稱:Protestr,代碼行數:20,代碼來源:RotationUtils.java

示例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);

    }
}
 
開發者ID:jiajunhui,項目名稱:PlayerBase,代碼行數:17,代碼來源:MainHolder.java

示例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);
    }
}
 
開發者ID:chenzj-king,項目名稱:RetrofitSample,代碼行數:18,代碼來源:BaseCompatActivity.java

示例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);



}
 
開發者ID:Justson,項目名稱:AgentWebX5,代碼行數:26,代碼來源:VideoImpl.java

示例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);
}
 
開發者ID:SavorGit,項目名稱:Hotspot-master-devp,代碼行數:16,代碼來源:ScreenOrientationUtil.java

示例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();
	}
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:16,代碼來源:StreamActivity.java

示例9: onConfigurationChanged

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
        //portrait
    } else {
        isLandscape = true;
        //landscape
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:TvShowActivity.java

示例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";
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:46,代碼來源:Form.java

示例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];
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:31,代碼來源:Launcher.java

示例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;
    }
}
 
開發者ID:yun2win,項目名稱:tvConnect_android,代碼行數:10,代碼來源:CaptureActivity.java

示例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;
}
 
開發者ID:WeDevelopTeam,項目名稱:HeroVideo-master,代碼行數:58,代碼來源:MediaPlayer.java

示例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;
}
 
開發者ID:lanyan520,項目名稱:Idea-ijkplayer,代碼行數:52,代碼來源:PlayerManager.java

示例15: orientationPortrait

public static ViewAction orientationPortrait() {
    return new OrientationChangeAction(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
 
開發者ID:fantasy1022,項目名稱:FancyTrendView,代碼行數:3,代碼來源:OrientationChangeAction.java


注:本文中的android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。