use of android.util.DisplayMetrics in project UltimateAndroid by cymcsg.
the class PullDoorView method setupView.
@SuppressLint("NewApi")
private void setupView() {
// 这个Interpolator你可以设置别的 我这里选择的是有弹跳效果的Interpolator
Interpolator polator = new BounceInterpolator();
mScroller = new Scroller(mContext, polator);
// 获取屏幕分辨率
WindowManager wm = (WindowManager) (mContext.getSystemService(Context.WINDOW_SERVICE));
DisplayMetrics dm = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(dm);
mScreenHeigh = dm.heightPixels;
mScreenWidth = dm.widthPixels;
// 这里你一定要设置成透明背景,不然会影响你看到底层布局
this.setBackgroundColor(Color.argb(0, 0, 0, 0));
mImgView = new ImageView(mContext);
mImgView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
// 填充整个屏幕
mImgView.setScaleType(ImageView.ScaleType.FIT_XY);
// 默认背景
mImgView.setImageResource(R.drawable.test);
addView(mImgView);
}
use of android.util.DisplayMetrics in project UltimateAndroid by cymcsg.
the class PullDoorView method setupView.
@SuppressLint("NewApi")
private void setupView() {
Interpolator polator = new BounceInterpolator();
mScroller = new Scroller(mContext, polator);
WindowManager wm = (WindowManager) (mContext.getSystemService(Context.WINDOW_SERVICE));
DisplayMetrics dm = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(dm);
mScreenHeigh = dm.heightPixels;
mScreenWidth = dm.widthPixels;
this.setBackgroundColor(Color.argb(0, 0, 0, 0));
mImgView = new ImageView(mContext);
mImgView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
mImgView.setScaleType(ImageView.ScaleType.FIT_XY);
mImgView.setImageResource(R.drawable.circle_button_ic_action_tick);
addView(mImgView);
}
use of android.util.DisplayMetrics in project UltimateAndroid by cymcsg.
the class ViewUtils method init.
public static void init(Context context) {
Resources res = context.getResources();
DisplayMetrics metrics = res.getDisplayMetrics();
width = metrics.widthPixels;
height = metrics.heightPixels;
}
use of android.util.DisplayMetrics in project GreenDroid by cyrilmottier.
the class PagedView method initPagedView.
private void initPagedView() {
final Context context = getContext();
mScroller = new Scroller(context, new DecelerateInterpolator());
final ViewConfiguration conf = ViewConfiguration.get(context);
// getScaledPagingTouchSlop() only available in API Level 8
mPagingTouchSlop = conf.getScaledTouchSlop() * 2;
mMaximumVelocity = conf.getScaledMaximumFlingVelocity();
final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
mMinimumVelocity = (int) (metrics.density * MINIMUM_PAGE_CHANGE_VELOCITY + 0.5f);
}
use of android.util.DisplayMetrics in project Libraries-for-Android-Developers by eoecn.
the class ResourcesCompat method getResources_getInteger.
/**
* Support implementation of {@code getResources().getInteger()} that we
* can use to simulate filtering based on width qualifiers on pre-3.2.
*
* @param context Context to load integers from on 3.2+ and to fetch the
* display metrics.
* @param id Id of integer to load.
* @return Associated integer value as reflected by the current display
* metrics.
*/
public static int getResources_getInteger(Context context, int id) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
return context.getResources().getInteger(id);
}
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
float widthDp = metrics.widthPixels / metrics.density;
if (id == R.integer.abs__max_action_buttons) {
if (widthDp >= 600) {
//values-w600dp
return 5;
}
if (widthDp >= 500) {
//values-w500dp
return 4;
}
if (widthDp >= 360) {
//values-w360dp
return 3;
}
//values
return 2;
}
throw new IllegalArgumentException("Unknown integer resource ID " + id);
}
Aggregations