本文整理汇总了Java中android.util.DisplayMetrics.DENSITY_LOW属性的典型用法代码示例。如果您正苦于以下问题:Java DisplayMetrics.DENSITY_LOW属性的具体用法?Java DisplayMetrics.DENSITY_LOW怎么用?Java DisplayMetrics.DENSITY_LOW使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.util.DisplayMetrics
的用法示例。
在下文中一共展示了DisplayMetrics.DENSITY_LOW属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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";
}
}
示例3: 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;
}
示例4: 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);
}
}
示例5: decodeSampledBitmapFromStream
private Bitmap decodeSampledBitmapFromStream(Uri imageUri, int reqWidth,
int reqHeight) throws IOException {
InputStream is = getUriAsStream(imageUri);
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = false;
options.outHeight = reqHeight;
options.outWidth = reqWidth;
options.inPreferQualityOverSpeed = false;
options.inDensity = DisplayMetrics.DENSITY_LOW;
options.inTempStorage = new byte[7680016];
Log.d(this.getClass().getName(),
"displaying image size width, height, inSampleSize "
+ options.outWidth + "," + options.outHeight + ","
+ options.inSampleSize);
Log.d(this.getClass().getName(), "free meomory before image load: "
+ Runtime.getRuntime().freeMemory());
Bitmap bitmap = BitmapFactory.decodeStream(new FlushedInputStream(is),
null, options);
Log.d(this.getClass().getName(), "free meomory after image load: "
+ Runtime.getRuntime().freeMemory());
return bitmap;
}
示例6: 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;
}
示例7: 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);
}
示例8: getDensity
/**
* Maps the current display density to a string constant.
* @param context context to use to retrieve the current display metrics
* @return a string constant representing the current display density, or the
* empty string if the density is unknown
*/
static String getDensity(final Context context) {
String densityStr = "";
final int density = context.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;
//todo uncomment in android sdk 25
//case DisplayMetrics.DENSITY_260:
// densityStr = "XHDPI";
// break;
case DisplayMetrics.DENSITY_280:
densityStr = "XHDPI";
break;
//todo uncomment in android sdk 25
//case DisplayMetrics.DENSITY_300:
// densityStr = "XHDPI";
// break;
case DisplayMetrics.DENSITY_XHIGH:
densityStr = "XHDPI";
break;
//todo uncomment in android sdk 25
//case DisplayMetrics.DENSITY_340:
// densityStr = "XXHDPI";
// break;
case DisplayMetrics.DENSITY_360:
densityStr = "XXHDPI";
break;
case DisplayMetrics.DENSITY_400:
densityStr = "XXHDPI";
break;
case DisplayMetrics.DENSITY_420:
densityStr = "XXHDPI";
break;
case DisplayMetrics.DENSITY_XXHIGH:
densityStr = "XXHDPI";
break;
case DisplayMetrics.DENSITY_560:
densityStr = "XXXHDPI";
break;
case DisplayMetrics.DENSITY_XXXHIGH:
densityStr = "XXXHDPI";
break;
default:
densityStr = "other";
break;
}
return densityStr;
}
示例9: isLdpiDensity
public static Boolean isLdpiDensity() {
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
return metrics.densityDpi == DisplayMetrics.DENSITY_LOW;
}
示例10: init
/**
* Save used widgets internal references
*/
private void init() {
mRadioGroup = (RadioGroup) findViewById(R.id.radio_time_increment_type);
mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup group, int checkedId) {
// Check which radio button was clicked
switch (checkedId) {
case R.id.radio_delay:
mTimeIncrementTypePosition = 0;
break;
case R.id.radio_bronstein:
mTimeIncrementTypePosition = 1;
break;
case R.id.radio_fischer:
mTimeIncrementTypePosition = 2;
break;
}
updateSubtitle();
}
});
mDelayBtn = (RadioButton) findViewById(R.id.radio_delay);
mBronsteinBtn = (RadioButton) findViewById(R.id.radio_bronstein);
mFischerBtn = (RadioButton) findViewById(R.id.radio_fischer);
// Setup subtitle text
mTimeIncrementSubtitleText = (TextView) findViewById(R.id.time_increment_type_subtitle);
// Remove subtitle text view from UI on hdpi and landscapes
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
DisplayMetrics metrics = new DisplayMetrics();
WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
windowManager.getDefaultDisplay().getMetrics(metrics);
switch (metrics.densityDpi) {
case DisplayMetrics.DENSITY_HIGH:
case DisplayMetrics.DENSITY_MEDIUM:
case DisplayMetrics.DENSITY_LOW:
findViewById(R.id.time_increment_type_subtitle).setVisibility(GONE);
break;
}
}
}
示例11: replaceCommentItem
private void replaceCommentItem(int index, com.google.api.services.blogger.model.Comment comment, Post post){
// getting author picture
Bitmap authorPic;
InputStream in = null;
try {
in = new java.net.URL("https:" + comment.getAuthor().getImage().getUrl()).openStream();
} catch (IOException e2){
Tools.loge(e2.getMessage());
}
BitmapFactory.Options options = new BitmapFactory.Options();
// Bitmaps are taking way to long to load -> Density = low
options.inDensity = DisplayMetrics.DENSITY_LOW;
options.inTargetDensity = mContext.getResources().getDisplayMetrics().densityDpi;
authorPic = BitmapFactory.decodeStream(in, null, options);
log(String.valueOf(authorPic == null));
DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics();
// minus padding...
float dpWidth = displayMetrics.widthPixels / displayMetrics.density - 10;
int pxSize = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
dpWidth * Float.valueOf("0.1"),
mContext.getResources().getDisplayMetrics());
authorPic = getCroppedBitmap(getResizedBitmap(authorPic, pxSize, pxSize));
comments.set(index, new Comment(
comment.getAuthor().getDisplayName(),
authorPic,
comments.get(index).blogId,
comments.get(index).postId,
comments.get(index).id,
comments.get(index).inReplyToId,
parseDateTime(comment.getUpdated(), mContext),
comment.getContent(),
post.getTitle()
));
log("Detailed comment: " +
comment.getAuthor().getDisplayName() + " " +
String.valueOf(authorPic == null) + " " +
comments.get(index).blogId + " " +
comments.get(index).postId + " " +
comments.get(index).id + " " +
comments.get(index).inReplyToId + " " +
parseDateTime(comment.getUpdated(), mContext) + " " +
comment.getContent() + " " +
post.getTitle()
);
}