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


Java DisplayMetrics.DENSITY_DEFAULT属性代码示例

本文整理汇总了Java中android.util.DisplayMetrics.DENSITY_DEFAULT属性的典型用法代码示例。如果您正苦于以下问题:Java DisplayMetrics.DENSITY_DEFAULT属性的具体用法?Java DisplayMetrics.DENSITY_DEFAULT怎么用?Java DisplayMetrics.DENSITY_DEFAULT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.util.DisplayMetrics的用法示例。


在下文中一共展示了DisplayMetrics.DENSITY_DEFAULT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getScreenType

private static int getScreenType(Context con) {
    if (mDeviceType == -1) {
        WindowManager wm = (WindowManager) con.getSystemService(Context.WINDOW_SERVICE);
        DisplayMetrics outMetrics = new DisplayMetrics();
        wm.getDefaultDisplay().getMetrics(outMetrics);
        int shortSize = Math.min(outMetrics.heightPixels, outMetrics.widthPixels);
        int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / outMetrics.densityDpi;
        if (shortSizeDp < 600) {
            // 0-599dp: "phone" UI with a separate status & navigation bar
            mDeviceType = DEVICE_PHONE;
        } else if (shortSizeDp < 720) {
            // 600-719dp: "phone" UI with modifications for larger screens
            mDeviceType = DEVICE_HYBRID;
        } else {
            // 720dp: "tablet" UI with a single combined status & navigation bar
            mDeviceType = DEVICE_TABLET;
        }
    }
    return mDeviceType;
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:20,代码来源:Utils.java

示例2: CrumbView

public CrumbView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    defaultPaint.setColor(fetchDefaultColour());

    int densityRatio = getResources().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT;
    dotInterval = 16 * densityRatio;
    dotRadius = 4 * densityRatio;
}
 
开发者ID:Deliganli,项目名称:crumber,代码行数:9,代码来源:CrumbView.java

示例3: temporaryRestoreDefaultDensity

/**
 * restores normal density without saving it for next start
 */
public void temporaryRestoreDefaultDensity(){
    Resources res = mActivity.getResources();
    DisplayMetrics displayMetrics = res.getDisplayMetrics();
    Configuration config = res.getConfiguration();
    displayMetrics.densityDpi = DisplayMetrics.DENSITY_DEFAULT;
    config.densityDpi = Configuration.DENSITY_DPI_UNDEFINED;
    res.updateConfiguration(config, displayMetrics);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:11,代码来源:DensityTweak.java

示例4: dpToPx

public static int dpToPx(int dp) {
  DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
  return  dp * (metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
}
 
开发者ID:saveendhiman,项目名称:FacebookReaction,代码行数:4,代码来源:DisplayUtil.java

示例5: convertPixelsToDp

public static float convertPixelsToDp(float px, Context context){
    Resources resources = context.getResources();
    DisplayMetrics metrics = resources.getDisplayMetrics();
    float dp = px / ((float)metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
    return dp;
}
 
开发者ID:adonixis,项目名称:android-submit-credit-card-flow,代码行数:6,代码来源:SubmitCreditCardActivity.java

示例6: convertDpToPixel

public static float convertDpToPixel(float dp, Context context) {
    Resources resources = context.getResources();
    DisplayMetrics metrics = resources.getDisplayMetrics();
    float px = dp * ((float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
    return px;
}
 
开发者ID:anikraj1994,项目名称:Remote,代码行数:6,代码来源:ViewMetrics.java

示例7: convertPixelsToDp

private int convertPixelsToDp(int px) {
    return px / (mDisplayMetrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
}
 
开发者ID:R12rus,项目名称:ShadowFrameLayout,代码行数:3,代码来源:ShadowFrameLayout.java

示例8: convertDpToPixel

public static int convertDpToPixel(float dp, Context context) {
  Resources resources = context.getResources();
  DisplayMetrics metrics = resources.getDisplayMetrics();
  return (int) (dp * (metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT));
}
 
开发者ID:DevAhamed,项目名称:MultiViewAdapter,代码行数:5,代码来源:DragAndDropActivity.java

示例9: ConvertTopx

private int ConvertTopx(float dp) {
    DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
    return ((int) (dp * ((float) metrics.densityDpi) / DisplayMetrics.DENSITY_DEFAULT));

}
 
开发者ID:coder3101,项目名称:Matrix-Calculator-for-Android,代码行数:5,代码来源:FillingMatrix.java

示例10: dpiFromPx

public static float dpiFromPx(int size, DisplayMetrics metrics){
    float densityRatio = (float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT;
    return (size / densityRatio);
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:4,代码来源:Utilities.java

示例11: FromDpToPixels

public static float FromDpToPixels(float dp, Context context) {
    Resources resources = context.getResources();
    DisplayMetrics metrics = resources.getDisplayMetrics();
    return dp * ((float)metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
}
 
开发者ID:humaniq,项目名称:humaniq-android,代码行数:5,代码来源:GraphicKeyView.java

示例12: convertDpToPixel

public static float convertDpToPixel(float dp, Context context){
    Resources resources = context.getResources();
    DisplayMetrics metrics = resources.getDisplayMetrics();
    return dp * ((float)metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
}
 
开发者ID:lurbas,项目名称:MaterialMasterDetail,代码行数:5,代码来源:ViewUtils.java

示例13: getPixelScaleFactor

private static float getPixelScaleFactor(Context context) {
    DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
    return (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT);
}
 
开发者ID:chenzj-king,项目名称:RetrofitSample,代码行数:4,代码来源:PixelUtil.java

示例14: convertPixelsToDp

/**
 * This method converts device specific pixels to density independent pixels.
 *
 * @param px A value in px (pixels) unit. Which we need to convert into db
 * @param context Context to get resources and device specific display metrics
 * @return A float value to represent dp equivalent to px value
 */
public static float convertPixelsToDp(float px, Context context){
    Resources resources = context.getResources();
    DisplayMetrics metrics = resources.getDisplayMetrics();
    float dp = px / ((float)metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
    return dp;
}
 
开发者ID:Bruno125,项目名称:Unofficial-Ups,代码行数:13,代码来源:UiUtils.java

示例15: convertDpToPixel

/**
 * This method converts dp unit to equivalent pixels, depending on device density.
 *
 * @param dp      A value in dp (density independent pixels) unit. Which we need to convert into pixels
 * @param context Context to get resources and device specific display metrics
 * @return A float value to represent px equivalent to dp depending on device density
 */
private static float convertDpToPixel(float dp, Context context) {
    Resources resources = context.getResources();
    DisplayMetrics metrics = resources.getDisplayMetrics();
    float px = dp * ((float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
    return px;
}
 
开发者ID:GeorgeArgyrakis,项目名称:FloatingKeyboard,代码行数:13,代码来源:FloatingKeyboardView.java


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