当前位置: 首页>>代码示例>>Java>>正文


Java Configuration.ORIENTATION_PORTRAIT属性代码示例

本文整理汇总了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;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:CrashDetails.java

示例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);
}
 
开发者ID:approov,项目名称:AppAuth-OAuth2-Books-Demo,代码行数:8,代码来源:FavoritesActivity.java

示例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());
    }
}
 
开发者ID:inceleb,项目名称:InstagramManager-Android,代码行数:10,代码来源:DetailActivity.java

示例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;
}
 
开发者ID:yangchaojiang,项目名称:yjPlay,代码行数:13,代码来源:VideoPlayUtils.java

示例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;
}
 
开发者ID:alibaba,项目名称:Tangram-Android,代码行数:7,代码来源:LinearScrollView.java

示例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;
}
 
开发者ID:TrustWallet,项目名称:trust-wallet-android,代码行数:12,代码来源:CameraSourcePreview.java

示例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;
}
 
开发者ID:StickyTolt,项目名称:ForeverLibrary,代码行数:12,代码来源:SystemBarTintManager.java

示例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;
}
 
开发者ID:CoderChoy,项目名称:BarcodeReaderView,代码行数:36,代码来源:CameraManager.java

示例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!");
        }
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:13,代码来源:ShortcutsCreation.java

示例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);
    }
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:35,代码来源:PlayerActivity.java

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

}
 
开发者ID:AnyRTC,项目名称:anyRTC-Meeting-Android,代码行数:15,代码来源:MeetingActivity.java

示例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
}
   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:13,代码来源:ListShower.java

示例13: onConfigurationChanged

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    isPortrait = newConfig.orientation == Configuration.ORIENTATION_PORTRAIT;
    requestVideoLayoutParam();
}
 
开发者ID:xinpianchang,项目名称:NSMPlayer-Android,代码行数:6,代码来源:BasicVideoViewActivity.java

示例14: isInPortraitMode

public boolean isInPortraitMode() {
    return _context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
}
 
开发者ID:gsantner,项目名称:markor,代码行数:3,代码来源:ContextUtils.java

示例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;
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:4,代码来源:Utils.java


注:本文中的android.content.res.Configuration.ORIENTATION_PORTRAIT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。