private void Init(Display display)
        {
            mScroller = new Scroller(Context);
            float density;

            if (display != null)
            {
                DisplayMetrics displayMetrics = new DisplayMetrics();
                display.GetMetrics(displayMetrics);
                density = displayMetrics.Density;
            }
            else
            {
                density = Context.Resources.DisplayMetrics.Density;
            }
            mDensityAdjustedSnapVelocity = (int)(density * SNAP_VELOCITY_DIP_PER_SECOND);

            ViewConfiguration configuration = ViewConfiguration.Get(Context);
            mTouchSlop = configuration.ScaledTouchSlop;
            mMaximumVelocity = configuration.ScaledMaximumFlingVelocity;
        }
Exemple #2
0
        public DisplayMetricsDensity GetScreenDensity(Display display)
        {
            Android.Util.DisplayMetrics metrics = new Android.Util.DisplayMetrics();
            display.GetMetrics(metrics);

            switch (metrics.DensityDpi)
            {
                case DisplayMetricsDensity.Low:
                    return DisplayMetricsDensity.Low;
                case DisplayMetricsDensity.Medium:
                    return DisplayMetricsDensity.Medium;
                case DisplayMetricsDensity.High:
                    return DisplayMetricsDensity.High;
                case DisplayMetricsDensity.Xhigh:
                    return DisplayMetricsDensity.Xhigh;
                case DisplayMetricsDensity.Tv:
                    return DisplayMetricsDensity.Tv;
            }

            return DisplayMetricsDensity.Default;
        }