本文整理汇总了Java中android.content.res.Configuration.ORIENTATION_PORTRAIT属性的典型用法代码示例。如果您正苦于以下问题:Java Configuration.ORIENTATION_PORTRAIT属性的具体用法?Java Configuration.ORIENTATION_PORTRAIT怎么用?Java Configuration.ORIENTATION_PORTRAIT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.content.res.Configuration
的用法示例。
在下文中一共展示了Configuration.ORIENTATION_PORTRAIT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOrientation
/**
* Returns the current device orientation.
*/
static String getOrientation(Context context) {
int orientation = context.getResources().getConfiguration().orientation;
switch(orientation)
{
case Configuration.ORIENTATION_LANDSCAPE:
return "Landscape";
case Configuration.ORIENTATION_PORTRAIT:
return "Portrait";
case Configuration.ORIENTATION_SQUARE:
return "Square";
case Configuration.ORIENTATION_UNDEFINED:
return "Unknown";
default:
return null;
}
}
示例2: bindFavoritesViews
private void bindFavoritesViews() {
GridLayoutManager gridLayoutManager = new GridLayoutManager(this,
getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ? 2 : 3);
booksAdapter = new BookListAdapter(selectionListener, gridLayoutManager.getSpanCount());
booksView.setLayoutManager(gridLayoutManager);
booksView.setAdapter(booksAdapter);
}
示例3: onMeasure
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
} else {
setMeasuredDimension(getMeasuredHeight(), getMeasuredHeight());
}
}
示例4: getOrientation
/***
* 获取当前手机状态
*
* @param activity 活动
* @return int orientation
*/
public static int getOrientation(@NonNull Activity activity) {
Resources resources = activity.getResources();
if (resources == null || resources.getConfiguration() == null) {
return Configuration.ORIENTATION_PORTRAIT;
}
return activity.getResources().getConfiguration().orientation;
}
示例5: getScreenWidth
private int getScreenWidth() {
Resources resources = getContext().getResources();
DisplayMetrics dm = resources.getDisplayMetrics();
Configuration configuration = resources.getConfiguration();
return configuration.orientation == Configuration.ORIENTATION_PORTRAIT ?
dm.widthPixels : dm.heightPixels;
}
示例6: isPortraitMode
private boolean isPortraitMode() {
int orientation = mContext.getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
return false;
}
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
return true;
}
Log.d(TAG, "isPortraitMode returning false by default");
return false;
}
示例7: SystemBarConfig
private SystemBarConfig(Activity activity, boolean translucentStatusBar, boolean traslucentNavBar) {
Resources res = activity.getResources();
mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
mSmallestWidthDp = getSmallestWidthDp(activity);
mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME);
mActionBarHeight = getActionBarHeight(activity);
mNavigationBarHeight = getNavigationBarHeight(activity);
mNavigationBarWidth = getNavigationBarWidth(activity);
mHasNavigationBar = (mNavigationBarHeight > 0);
mTranslucentStatusBar = translucentStatusBar;
mTranslucentNavBar = traslucentNavBar;
}
示例8: getFramingRectInPreview
/**
* Like {@link #getFramingRect} but coordinates are in terms of the preview frame,
* not UI / screen.
*
* @return {@link Rect} expressing barcode scan area in terms of the preview size
*/
public synchronized Rect getFramingRectInPreview() {
if (framingRectInPreview == null) {
Rect framingRect = getFramingRect();
if (framingRect == null) {
return null;
}
Rect rect = new Rect(framingRect);
Point cameraResolution = configManager.getCameraResolution();
Point screenResolution = configManager.getScreenResolution();
if (cameraResolution == null || screenResolution == null) {
// Called early, before init even finished
return null;
}
if (view.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
rect.left = rect.left * cameraResolution.y / screenResolution.x;
rect.right = rect.right * cameraResolution.y / screenResolution.x;
rect.top = rect.top * cameraResolution.x / screenResolution.y;
rect.bottom = rect.bottom * cameraResolution.x / screenResolution.y;
} else {
rect.left = rect.left * cameraResolution.x / screenResolution.x;
rect.right = rect.right * cameraResolution.x / screenResolution.x;
rect.top = rect.top * cameraResolution.y / screenResolution.y;
rect.bottom = rect.bottom * cameraResolution.y / screenResolution.y;
}
framingRectInPreview = rect;
}
return framingRectInPreview;
}
示例9: init
public void init() throws NullPointerException{
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
if (shortcutsBuilder.isNormal() && shortcutsBuilder.getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
initNormalShortcuts();
} else if (shortcutsBuilder.isLauncher3() && shortcutsBuilder.getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
initLauncher3Shortcuts();
} else if (shortcutsBuilder.getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
Log.e(TAG, "Shortcuts not working in LANDSCAPE mode!");
} else {
throw new NullPointerException(TAG + "No normal shortcuts/laucher3 shortcuts defined!");
}
}
}
示例10: setLockRotation
private void setLockRotation(boolean avpLock) {
Display display = getWindowManager().getDefaultDisplay();
int rotation = display.getRotation();
if (DBG) Log.d(TAG, "rotation status: " + rotation);
boolean systemLock;
try {
systemLock = 1 != Settings.System.getInt(getContentResolver(), Settings.System.ACCELEROMETER_ROTATION);
} catch (SettingNotFoundException e) {
systemLock = false;
}
if (DBG) Log.d(TAG, "avpLock: " + avpLock + " systemLock: " + systemLock);
if (avpLock || systemLock) {
int tmpOrientation = getResources().getConfiguration().orientation;
int wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
if (tmpOrientation == Configuration.ORIENTATION_LANDSCAPE) {
if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90)
wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
else
wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
setRequestedOrientation(wantedOrientation);
}
else if (tmpOrientation == Configuration.ORIENTATION_PORTRAIT || tmpOrientation == Configuration.ORIENTATION_UNDEFINED) {
if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90)
wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
else
wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
setRequestedOrientation(wantedOrientation);
}
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
}
示例11: onConfigurationChanged
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
if (mMeetKit!=null){
mMeetKit.setScreenToLandscape();
}
} else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
if (mMeetKit!=null){
mMeetKit.setScreenToPortrait();
}
}
}
示例12: onConfigurationChanged
@Override
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
{
// land do nothing is ok
}
else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
{
// port do nothing is ok
}
}
示例13: onConfigurationChanged
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
isPortrait = newConfig.orientation == Configuration.ORIENTATION_PORTRAIT;
requestVideoLayoutParam();
}
示例14: isInPortraitMode
public boolean isInPortraitMode() {
return _context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
}
示例15: getOrientation
public static int getOrientation(Activity activity) {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && activity.isInMultiWindowMode() ?
Configuration.ORIENTATION_PORTRAIT : activity.getResources().getConfiguration().orientation;
}