當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。