當前位置: 首頁>>代碼示例>>Java>>正文


Java DisplayMetrics.DENSITY_HIGH屬性代碼示例

本文整理匯總了Java中android.util.DisplayMetrics.DENSITY_HIGH屬性的典型用法代碼示例。如果您正苦於以下問題:Java DisplayMetrics.DENSITY_HIGH屬性的具體用法?Java DisplayMetrics.DENSITY_HIGH怎麽用?Java DisplayMetrics.DENSITY_HIGH使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.util.DisplayMetrics的用法示例。


在下文中一共展示了DisplayMetrics.DENSITY_HIGH屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getLauncherIconDensity

private int getLauncherIconDensity(int requiredSize) {
    // Densities typically defined by an app.
    int[] densityBuckets = new int[] {
            DisplayMetrics.DENSITY_LOW,
            DisplayMetrics.DENSITY_MEDIUM,
            DisplayMetrics.DENSITY_TV,
            DisplayMetrics.DENSITY_HIGH,
            DisplayMetrics.DENSITY_XHIGH,
            DisplayMetrics.DENSITY_XXHIGH,
            DisplayMetrics.DENSITY_XXXHIGH
    };

    int density = DisplayMetrics.DENSITY_XXXHIGH;
    for (int i = densityBuckets.length - 1; i >= 0; i--) {
        float expectedSize = ICON_SIZE_DEFINED_IN_APP_DP * densityBuckets[i]
                / DisplayMetrics.DENSITY_DEFAULT;
        if (expectedSize >= requiredSize) {
            density = densityBuckets[i];
        }
    }

    return density;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:23,代碼來源:InvariantDeviceProfile.java

示例2: getAvatarUrl

public String getAvatarUrl(Context context) {
    if (context != null) {
        final int densityDpi = context.getResources().getDisplayMetrics().densityDpi;

        if ((densityDpi > DisplayMetrics.DENSITY_XXXHIGH ||
                densityDpi > DisplayMetrics.DENSITY_XXHIGH ||
                densityDpi > DisplayMetrics.DENSITY_XHIGH) && xhdpi_link != null) {
            return xhdpi_link;
        } else if (densityDpi > DisplayMetrics.DENSITY_HIGH && hdpi_link != null) {
            return hdpi_link;
        } else if (densityDpi > DisplayMetrics.DENSITY_MEDIUM && mdpi_link != null) {
            return mdpi_link;
        } else {
            return ldpi_link;
        }
    }
    return null;
}
 
開發者ID:Dentacoin,項目名稱:aftercare-app-android,代碼行數:18,代碼來源:DCAvatar.java

示例3: isTabletDevice

public boolean isTabletDevice(Context activityContext) {
    boolean device_large = ((activityContext.getResources().getConfiguration().screenLayout &
            Configuration.SCREENLAYOUT_SIZE_MASK) ==
            Configuration.SCREENLAYOUT_SIZE_LARGE);

    if (device_large) {
        DisplayMetrics metrics = new DisplayMetrics();
        Activity activity = (Activity) activityContext;
        activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);

        if (metrics.densityDpi == DisplayMetrics.DENSITY_DEFAULT
                || metrics.densityDpi == DisplayMetrics.DENSITY_HIGH
                || metrics.densityDpi == DisplayMetrics.DENSITY_MEDIUM
                || metrics.densityDpi == DisplayMetrics.DENSITY_TV
                || metrics.densityDpi == DisplayMetrics.DENSITY_XHIGH) {
            return true;
        }
    }
    return false;
}
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:20,代碼來源:Comman.java

示例4: getDpi

@TargetApi(Build.VERSION_CODES.DONUT)
public static String getDpi(WindowManager windowManager) {
  if (windowManager == null) {
    return "";
  }
  int densityDpi = getMetricsSize(windowManager);
  switch (densityDpi) {
    case DisplayMetrics.DENSITY_LOW:
      return "ldpi";
    case DisplayMetrics.DENSITY_MEDIUM:
      return "mdpi";
    case DisplayMetrics.DENSITY_HIGH:
      return "hdpi";
    case DisplayMetrics.DENSITY_XHIGH:
      return "xhpdi";
    case DisplayMetrics.DENSITY_XXHIGH:
    default:
      return "xxhdpi";
  }
}
 
開發者ID:Sugarya,項目名稱:Closet,代碼行數:20,代碼來源:DisplayUtil.java

示例5: init

public static void init(final Resources res) {
    // The proximate bogus down move up event hack is needed for a device such like,
    // 1) is large tablet, or 2) is small tablet and the screen density is less than hdpi.
    // Though it seems odd to use screen density as criteria of the quality of the touch
    // screen, the small table that has a less density screen than hdpi most likely has been
    // made with the touch screen that needs the hack.
    final int screenMetrics = res.getInteger(R.integer.config_screen_metrics);
    final boolean isLargeTablet = (screenMetrics == Constants.SCREEN_METRICS_LARGE_TABLET);
    final boolean isSmallTablet = (screenMetrics == Constants.SCREEN_METRICS_SMALL_TABLET);
    final int densityDpi = res.getDisplayMetrics().densityDpi;
    final boolean hasLowDensityScreen = (densityDpi < DisplayMetrics.DENSITY_HIGH);
    final boolean needsTheHack = isLargeTablet || (isSmallTablet && hasLowDensityScreen);
    if (DEBUG_MODE) {
        final int sw = res.getConfiguration().smallestScreenWidthDp;
        Log.d(TAG, "needsProximateBogusDownMoveUpEventHack=" + needsTheHack
                + " smallestScreenWidthDp=" + sw + " densityDpi=" + densityDpi
                + " screenMetrics=" + screenMetrics);
    }
    sNeedsProximateBogusDownMoveUpEventHack = needsTheHack;
}
 
開發者ID:rkkr,項目名稱:simple-keyboard,代碼行數:20,代碼來源:BogusMoveEventDetector.java

示例6: getDensityPostfix

public static String getDensityPostfix(Resources res) {
    String result = null;
    switch (res.getDisplayMetrics().densityDpi) {
        case DisplayMetrics.DENSITY_LOW:
            result = "ldpi";
            break;
        case DisplayMetrics.DENSITY_MEDIUM:
            result = "mdpi";
            break;
        case DisplayMetrics.DENSITY_HIGH:
            result = "hdpi";
            break;
        case DisplayMetrics.DENSITY_XHIGH:
            result = "xhdpi";
            break;
        case DisplayMetrics.DENSITY_XXHIGH:
            result = "xxhdpi";
            break;
        case DisplayMetrics.DENSITY_XXXHIGH:
            result = "xxxhdpi";
            break;
    }
    return result;
}
 
開發者ID:Blankeer,項目名稱:MDWechat,代碼行數:24,代碼來源:NinePatchBitmapFactory.java

示例7: getDensityString

private static String getDensityString(DisplayMetrics displayMetrics) {
  switch (displayMetrics.densityDpi) {
    case DisplayMetrics.DENSITY_LOW:
      return "ldpi";
    case DisplayMetrics.DENSITY_MEDIUM:
      return "mdpi";
    case DisplayMetrics.DENSITY_HIGH:
      return "hdpi";
    case DisplayMetrics.DENSITY_XHIGH:
      return "xhdpi";
    case DisplayMetrics.DENSITY_XXHIGH:
      return "xxhdpi";
    case DisplayMetrics.DENSITY_XXXHIGH:
      return "xxxhdpi";
    case DisplayMetrics.DENSITY_TV:
      return "tvdpi";
    default:
      return String.valueOf(displayMetrics.densityDpi);
  }
}
 
開發者ID:rogues-dev,項目名稱:superglue,代碼行數:20,代碼來源:BugReportLens.java

示例8: getDensity

public static String getDensity(Context ctx) {
    String densityStr = null;
    final int density = ctx.getResources().getDisplayMetrics().densityDpi;
    switch (density) {
        case DisplayMetrics.DENSITY_LOW:
            densityStr = "LDPI";
            break;
        case DisplayMetrics.DENSITY_MEDIUM:
            densityStr = "MDPI";
            break;
        case DisplayMetrics.DENSITY_TV:
            densityStr = "TVDPI";
            break;
        case DisplayMetrics.DENSITY_HIGH:
            densityStr = "HDPI";
            break;
        case DisplayMetrics.DENSITY_XHIGH:
            densityStr = "XHDPI";
            break;
        case DisplayMetrics.DENSITY_400:
            densityStr = "XMHDPI";
            break;
        case DisplayMetrics.DENSITY_XXHIGH:
            densityStr = "XXHDPI";
            break;
        case DisplayMetrics.DENSITY_XXXHIGH:
            densityStr = "XXXHDPI";
            break;
    }
    return densityStr;
}
 
開發者ID:jeasinlee,項目名稱:AndroidBasicLibs,代碼行數:31,代碼來源:DeviceUtils.java

示例9: getSelectedItemFromDensity

/**
 *
 * @param density
 * @return -1 if the given density does not match any of the choices we have
 */
private int getSelectedItemFromDensity(int density) {
    switch (density) {
        case DisplayMetrics.DENSITY_MEDIUM:
            return 0;
        case DisplayMetrics.DENSITY_HIGH:
            return 1;
        case DisplayMetrics.DENSITY_XHIGH:
            return 2;
        case DisplayMetrics.DENSITY_XXHIGH:
            return 3;
        default:
            return -1;
    }
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:19,代碼來源:DensityTweak.java

示例10: getDensityFromSelectedItem

private int getDensityFromSelectedItem(int selection) {
    switch (selection) {
        case 0:
            return DisplayMetrics.DENSITY_MEDIUM;
        case 1:
            return DisplayMetrics.DENSITY_HIGH;
        case 2:
        default: // default should never happen
            return DisplayMetrics.DENSITY_XHIGH;
        case 3:
            return DisplayMetrics.DENSITY_XXHIGH;
    }
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:13,代碼來源:DensityTweak.java

示例11: createDefaultBitmapOptions

public static BitmapFactory.Options createDefaultBitmapOptions()
{
    BitmapFactory.Options options = new BitmapFactory.Options(); 
    //Assume high density images. Providing alternative url-images for
    //different densities is quite rare.
    options.inDensity = DisplayMetrics.DENSITY_HIGH;
    options.inScaled = false;
    return options;
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-android,代碼行數:9,代碼來源:ImageTask.java

示例12: LinearColorBar

public LinearColorBar(Context context, AttributeSet attrs) {
    super(context, attrs);
    setWillNotDraw(false);
    mPaint.setStyle(Paint.Style.FILL);
    mColorGradientPaint.setStyle(Paint.Style.FILL);
    mColorGradientPaint.setAntiAlias(true);
    mEdgeGradientPaint.setStyle(Paint.Style.STROKE);
    mLineWidth = getResources().getDisplayMetrics().densityDpi >= DisplayMetrics.DENSITY_HIGH
            ? 2 : 1;
    mEdgeGradientPaint.setStrokeWidth(mLineWidth);
    mEdgeGradientPaint.setAntiAlias(true);
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:12,代碼來源:LinearColorBar.java

示例13: onCreate

@Override
protected void onCreate(Bundle savedInstanceState)
{
	super.onCreate(savedInstanceState);

	Intent intent = getIntent();
	mNewsTitle = intent.getStringExtra("news_title");
	mNewsUrl = intent.getStringExtra("news_url");

	setActionBarTitle(mNewsTitle);

	int screenDensity = getResources().getDisplayMetrics().densityDpi;
	WebSettings.ZoomDensity zoomDensity = WebSettings.ZoomDensity.MEDIUM;
	switch (screenDensity)
	{
		case DisplayMetrics.DENSITY_LOW:
		{
			zoomDensity = WebSettings.ZoomDensity.CLOSE;
			break;
		}
		case DisplayMetrics.DENSITY_MEDIUM:
		{
			zoomDensity = WebSettings.ZoomDensity.MEDIUM;
			break;
		}
		case DisplayMetrics.DENSITY_HIGH:
		{
			zoomDensity = WebSettings.ZoomDensity.FAR;
			break;
		}
	}
	// 設置默認縮放方式尺寸
	getWebview().getSettings().setDefaultZoom(zoomDensity);
	getWebview().getSettings().setBuiltInZoomControls(true);
	getWebview().loadUrl(mNewsUrl);
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:36,代碼來源:BaiduNewsDetailActivity.java

示例14: onCreate

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gpstrack_map);

    Bundle mExtras = getIntent().getExtras();
    if (mExtras != null) {
        mResource = getResources();
        mErrMsg = mResource.getString(R.string.error_056);
        //get the the track id
        mTrackId = mExtras.getLong(GPS_TRACK_ID);

        DBAdapter dbAdapter = new DBAdapter(this);
        Cursor c = dbAdapter.fetchRecord(DBAdapter.TABLE_NAME_GPSTRACK, DBAdapter.COL_LIST_GPSTRACK_TABLE, mTrackId);
        mInfoName = c != null ? c.getString(DBAdapter.COL_POS_GEN_NAME) : "";
        mInfoDateTimeStart = Utils.getFormattedDateTime((c != null ? c.getLong(DBAdapter.COL_POS_GPSTRACK__DATE) : 0) * 1000, false); //format[0].format(new Date(c.getLong(DBAdapter.COL_POS_GPSTRACK__DATE) * 1000));
        mInfoDateTimeEnd = Utils.getFormattedDateTime(((c != null ? c.getLong(DBAdapter.COL_POS_GPSTRACK__DATE) : 0) * 1000) + ((c != null ? c.getLong(DBAdapter.COL_POS_GPSTRACK__TOTALTIME) : 0) * 1000), false);

        mInfoTotalTime = c != null ? c.getLong(DBAdapter.COL_POS_GPSTRACK__TOTALTIME) : 0;
        mInfoMovingTime = c != null ? c.getLong(DBAdapter.COL_POS_GPSTRACK__MOVINGTIME) : 0;
        mInfoTotalPauseTime = c != null ? c.getLong(DBAdapter.COL_POS_GPSTRACK__TOTALPAUSETIME) : 0;
        mInfoNonMovingTime = mInfoTotalTime - mInfoTotalPauseTime - mInfoMovingTime;
        mInfoDistance = c != null ? c.getDouble(DBAdapter.COL_POS_GPSTRACK__DISTANCE) : 0;
        mInfoMaxSpeed = c != null ? c.getDouble(DBAdapter.COL_POS_GPSTRACK__MAXSPEED) : 0;
        mInfoAvgSpeed = c != null ? c.getDouble(DBAdapter.COL_POS_GPSTRACK__AVGSPEED) : 0;
        mInfoAvgMovingSpeed = c != null ? c.getDouble(DBAdapter.COL_POS_GPSTRACK__AVGMOVINGSPEED) : 0;
        mCarUOMLengthCode = dbAdapter.getUOMCode(dbAdapter.getCarUOMLengthID(c != null ? c.getLong(DBAdapter.COL_POS_GPSTRACK__CAR_ID) : -1));
        if (c != null) {
            c.close();
        }

        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        if (metrics.densityDpi <= DisplayMetrics.DENSITY_HIGH) {
            trackLineWidth = 3;
        }

        loadTrackFiles = true;
        setUpMapIfNeeded();
    }
}
 
開發者ID:mkeresztes,項目名稱:AndiCar,代碼行數:41,代碼來源:GPSTrackMap.java

示例15: isHdpiDensity

public static Boolean isHdpiDensity() {
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    return metrics.densityDpi == DisplayMetrics.DENSITY_HIGH;
}
 
開發者ID:yongbeam,項目名稱:AirQuickUtils,代碼行數:5,代碼來源:AirScreen.java


注:本文中的android.util.DisplayMetrics.DENSITY_HIGH屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。