Search in sources :

Example 36 with DisplayMetrics

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;
}
Also used : DisplayMetrics(android.util.DisplayMetrics)

Example 37 with DisplayMetrics

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;
}
Also used : Bitmap(android.graphics.Bitmap) SharedPreferences(android.content.SharedPreferences) Canvas(android.graphics.Canvas) DisplayMetrics(android.util.DisplayMetrics)

Example 38 with DisplayMetrics

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;
}
Also used : DisplayMetrics(android.util.DisplayMetrics) Implementation(org.robolectric.annotation.Implementation)

Example 39 with DisplayMetrics

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);
}
Also used : Bitmap(android.graphics.Bitmap) DisplayMetrics(android.util.DisplayMetrics) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 40 with DisplayMetrics

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);
}
Also used : DisplayMetrics(android.util.DisplayMetrics)

Aggregations

DisplayMetrics (android.util.DisplayMetrics)772 WindowManager (android.view.WindowManager)107 Resources (android.content.res.Resources)99 Display (android.view.Display)78 Configuration (android.content.res.Configuration)61 Point (android.graphics.Point)57 View (android.view.View)52 SuppressLint (android.annotation.SuppressLint)47 Bitmap (android.graphics.Bitmap)42 Paint (android.graphics.Paint)42 Activity (android.app.Activity)32 ImageView (android.widget.ImageView)27 AssetManager (android.content.res.AssetManager)25 TypedArray (android.content.res.TypedArray)25 Context (android.content.Context)23 TypedValue (android.util.TypedValue)23 ViewGroup (android.view.ViewGroup)23 TextView (android.widget.TextView)22 Intent (android.content.Intent)21 RelativeLayout (android.widget.RelativeLayout)20