use of android.util.DisplayMetrics in project android-common by litesuits.
the class DisplayUtil method printDisplayInfo.
/**
* 打印 显示信息
*/
public static DisplayMetrics printDisplayInfo(Context context) {
DisplayMetrics dm = getDisplayMetrics(context);
if (Log.isPrint) {
StringBuilder sb = new StringBuilder();
sb.append("_______ 显示信息: ");
sb.append("\ndensity :").append(dm.density);
sb.append("\ndensityDpi :").append(dm.densityDpi);
sb.append("\nheightPixels :").append(dm.heightPixels);
sb.append("\nwidthPixels :").append(dm.widthPixels);
sb.append("\nscaledDensity :").append(dm.scaledDensity);
sb.append("\nxdpi :").append(dm.xdpi);
sb.append("\nydpi :").append(dm.ydpi);
Log.i(TAG, sb.toString());
}
return dm;
}
use of android.util.DisplayMetrics in project NotificationPeekPort by lzanita09.
the class WallpaperFactory method getPrefSystemWallpaper.
/**
* Create a bitmap that is blurred and dimmed with the amount that user has selected.
*
* @return Background bitmap.
*/
public Bitmap getPrefSystemWallpaper() {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext);
float radius = preferences.getFloat(PreferenceKeys.PREF_RADIUS, ImageBlurrer.MAX_SUPPORTED_BLUR_PIXELS);
int dim = preferences.getInt(PreferenceKeys.PREF_DIM, DEFAULT_MAX_DIM);
DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics();
// Blur
ImageBlurrer imageBlurrer = new ImageBlurrer(mContext);
Bitmap blurred = imageBlurrer.blurBitmap(drawableToBitmap(mWallpaperManager.getFastDrawable(), displayMetrics.widthPixels), radius);
// Dim
Canvas c = new Canvas(blurred);
c.drawColor(Color.argb(255 - dim, 0, 0, 0));
return blurred;
}
use of android.util.DisplayMetrics in project robolectric by robolectric.
the class ShadowResources method getSystem.
@Implementation
public static Resources getSystem() {
if (system == null) {
AssetManager assetManager = AssetManager.getSystem();
DisplayMetrics metrics = new DisplayMetrics();
Configuration config = new Configuration();
system = new Resources(assetManager, metrics, config);
}
return system;
}
use of android.util.DisplayMetrics in project robolectric by robolectric.
the class ShadowBitmapTest method shouldSetDensity.
@Test
@Config(minSdk = JELLY_BEAN_MR1)
public void shouldSetDensity() {
final Bitmap bitmap = Bitmap.createBitmap(new DisplayMetrics(), 100, 100, Bitmap.Config.ARGB_8888);
bitmap.setDensity(1000);
assertThat(bitmap.getDensity()).isEqualTo(1000);
}
use of android.util.DisplayMetrics in project android-Ultra-Pull-To-Refresh by liaohuqiu.
the class MaterialProgressDrawable method setSizeParameters.
private void setSizeParameters(double progressCircleWidth, double progressCircleHeight, double centerRadius, double strokeWidth, float arrowWidth, float arrowHeight) {
final Ring ring = mRing;
final DisplayMetrics metrics = mResources.getDisplayMetrics();
final float screenDensity = metrics.density;
mWidth = progressCircleWidth * screenDensity;
mHeight = progressCircleHeight * screenDensity;
ring.setStrokeWidth((float) strokeWidth * screenDensity);
ring.setCenterRadius(centerRadius * screenDensity);
ring.setColorIndex(0);
ring.setArrowDimensions(arrowWidth * screenDensity, arrowHeight * screenDensity);
ring.setInsets((int) mWidth, (int) mHeight);
setUp(mWidth);
}
Aggregations