Search in sources :

Example 31 with DisplayMetrics

use of android.util.DisplayMetrics in project ListenerMusicPlayer by hefuyicoder.

the class DensityUtil method getScreenWidth.

public static int getScreenWidth(Context context) {
    DisplayMetrics displayMetrics = new DisplayMetrics();
    ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    return displayMetrics.widthPixels;
}
Also used : Activity(android.app.Activity) DisplayMetrics(android.util.DisplayMetrics)

Example 32 with DisplayMetrics

use of android.util.DisplayMetrics in project QuickReturn by lawloretienne.

the class QuickReturnUtils method px2dp.

public static int px2dp(Context context, int px) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    DisplayMetrics displaymetrics = new DisplayMetrics();
    display.getMetrics(displaymetrics);
    return (int) (px / displaymetrics.density + 0.5f);
}
Also used : DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 33 with DisplayMetrics

use of android.util.DisplayMetrics in project QuickReturn by lawloretienne.

the class QuickReturnUtils method dp2px.

public static int dp2px(Context context, int dp) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    DisplayMetrics displaymetrics = new DisplayMetrics();
    display.getMetrics(displaymetrics);
    return (int) (dp * displaymetrics.density + 0.5f);
}
Also used : DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 34 with DisplayMetrics

use of android.util.DisplayMetrics in project TwinklingRefreshLayout by lcodecorex.

the class ProgressLayout method setSize.

/**
     * One of DEFAULT, or LARGE.
     */
public void setSize(int size) {
    if (size != MaterialProgressDrawable.LARGE && size != MaterialProgressDrawable.DEFAULT) {
        return;
    }
    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    if (size == MaterialProgressDrawable.LARGE) {
        mCircleHeight = mCircleWidth = (int) (CIRCLE_DIAMETER_LARGE * metrics.density);
    } else {
        mCircleHeight = mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density);
    }
    // force the bounds of the progress circle inside the circle view to
    // update by setting it to null before updating its size and then
    // re-setting it
    mCircleView.setImageDrawable(null);
    mProgress.updateSizes(size);
    mCircleView.setImageDrawable(mProgress);
}
Also used : DisplayMetrics(android.util.DisplayMetrics)

Example 35 with DisplayMetrics

use of android.util.DisplayMetrics in project TwinklingRefreshLayout by lcodecorex.

the class ScrollingUtil method getScreenHeight.

public static int getScreenHeight(Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics dm = new DisplayMetrics();
    windowManager.getDefaultDisplay().getMetrics(dm);
    return dm.heightPixels;
}
Also used : DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager)

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