Search in sources :

Example 21 with DisplayMetrics

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);
}
Also used : BounceInterpolator(android.view.animation.BounceInterpolator) BounceInterpolator(android.view.animation.BounceInterpolator) Interpolator(android.view.animation.Interpolator) Scroller(android.widget.Scroller) ImageView(android.widget.ImageView) DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager) SuppressLint(android.annotation.SuppressLint)

Example 22 with DisplayMetrics

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);
}
Also used : BounceInterpolator(android.view.animation.BounceInterpolator) BounceInterpolator(android.view.animation.BounceInterpolator) Interpolator(android.view.animation.Interpolator) Scroller(android.widget.Scroller) ImageView(android.widget.ImageView) DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager) SuppressLint(android.annotation.SuppressLint)

Example 23 with DisplayMetrics

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

Example 24 with DisplayMetrics

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);
}
Also used : Context(android.content.Context) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ViewConfiguration(android.view.ViewConfiguration) Scroller(android.widget.Scroller) DisplayMetrics(android.util.DisplayMetrics)

Example 25 with DisplayMetrics

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

Aggregations

DisplayMetrics (android.util.DisplayMetrics)751 WindowManager (android.view.WindowManager)103 Resources (android.content.res.Resources)95 Display (android.view.Display)75 Configuration (android.content.res.Configuration)58 Point (android.graphics.Point)56 View (android.view.View)48 SuppressLint (android.annotation.SuppressLint)44 Paint (android.graphics.Paint)42 Bitmap (android.graphics.Bitmap)41 Activity (android.app.Activity)32 ImageView (android.widget.ImageView)26 TypedArray (android.content.res.TypedArray)25 AssetManager (android.content.res.AssetManager)24 TypedValue (android.util.TypedValue)23 ViewGroup (android.view.ViewGroup)22 TextView (android.widget.TextView)21 Intent (android.content.Intent)20 FrameLayout (android.widget.FrameLayout)19 RelativeLayout (android.widget.RelativeLayout)19