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;
}
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);
}
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);
}
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);
}
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;
}
Aggregations