List of usage examples for android.support.v4.content.res ConfigurationHelper getScreenHeightDp
public static int getScreenHeightDp(@NonNull Resources resources)
From source file:android.support.v7.view.ActionBarPolicy.java
/** * Returns the maximum number of action buttons that should be permitted within an action * bar/action mode. This will be used to determine how many showAsAction="ifRoom" items can fit. * "always" items can override this.//from w ww .j a v a2s . c o m */ public int getMaxActionButtons() { final Resources res = mContext.getResources(); final int widthDp = ConfigurationHelper.getScreenWidthDp(res); final int heightDp = ConfigurationHelper.getScreenHeightDp(res); final int smallest = ConfigurationHelper.getSmallestScreenWidthDp(res); if (smallest > 600 || widthDp > 600 || (widthDp > 960 && heightDp > 720) || (widthDp > 720 && heightDp > 960)) { // For values-w600dp, values-sw600dp and values-xlarge. return 5; } else if (widthDp >= 500 || (widthDp > 640 && heightDp > 480) || (widthDp > 480 && heightDp > 640)) { // For values-w500dp and values-large. return 4; } else if (widthDp >= 360) { // For values-w360dp. return 3; } else { return 2; } }
From source file:be.ugent.zeus.hydra.views.ButtonBarLayout.java
public ButtonBarLayout(Context context, AttributeSet attrs) { super(context, attrs); final boolean allowStackingDefault = ConfigurationHelper .getScreenHeightDp(getResources()) >= ALLOW_STACKING_MIN_HEIGHT_DP; final TypedArray ta = context.obtainStyledAttributes(attrs, android.support.v7.appcompat.R.styleable.ButtonBarLayout); mAllowStacking = allowStackingDefault; ta.recycle();//w ww. ja v a 2s. c om }
From source file:android.support.design.widget.FloatingActionButton.java
private int getSizeDimension(@Size final int size) { final Resources res = getResources(); switch (size) { case SIZE_AUTO: // If we're set to auto, grab the size from resources and refresh final int width = ConfigurationHelper.getScreenWidthDp(res); final int height = ConfigurationHelper.getScreenHeightDp(res); return Math.max(width, height) < AUTO_MINI_LARGEST_SCREEN_WIDTH ? getSizeDimension(SIZE_MINI) : getSizeDimension(SIZE_NORMAL); case SIZE_MINI: return res.getDimensionPixelSize(R.dimen.design_fab_size_mini); case SIZE_NORMAL: default:/*from w ww . jav a 2 s . c o m*/ return res.getDimensionPixelSize(R.dimen.design_fab_size_normal); } }