public static float GetDpi(this global::Android.App.Activity activity)
        {
            var metrics = new global::Android.Util.DisplayMetrics();

            activity.WindowManager.DefaultDisplay.GetMetrics(metrics);
            return(metrics.Xdpi);
        }
            public unsafe DisplayMetricsScreenDimensions(global::Android.Util.DisplayMetrics p0)
                : base(IntPtr.Zero, JniHandleOwnership.DoNotTransfer)
            {
                if (Handle != IntPtr.Zero)
                {
                    return;
                }

                try {
                    JValue *__args = stackalloc JValue [1];
                    __args [0] = new JValue(p0);
                    if (GetType() != typeof(DisplayMetricsScreenDimensions))
                    {
                        SetHandle(
                            global::Android.Runtime.JNIEnv.StartCreateInstance(GetType(), "(Landroid/util/DisplayMetrics;)V", __args),
                            JniHandleOwnership.TransferLocalRef);
                        global::Android.Runtime.JNIEnv.FinishCreateInstance(Handle, "(Landroid/util/DisplayMetrics;)V", __args);
                        return;
                    }

                    if (id_ctor_Landroid_util_DisplayMetrics_ == IntPtr.Zero)
                    {
                        id_ctor_Landroid_util_DisplayMetrics_ = JNIEnv.GetMethodID(class_ref, "<init>", "(Landroid/util/DisplayMetrics;)V");
                    }
                    SetHandle(
                        global::Android.Runtime.JNIEnv.StartCreateInstance(class_ref, id_ctor_Landroid_util_DisplayMetrics_, __args),
                        JniHandleOwnership.TransferLocalRef);
                    JNIEnv.FinishCreateInstance(Handle, class_ref, id_ctor_Landroid_util_DisplayMetrics_, __args);
                } finally {
                }
            }
        public static unsafe int GetDefaultImageSizeForCurrentDisplay(global::Android.Util.DisplayMetrics displayMetrics)
        {
            const string __id = "getDefaultImageSizeForCurrentDisplay.(Landroid/util/DisplayMetrics;)I";

            try {
                JniArgumentValue *__args = stackalloc JniArgumentValue [1];
                __args [0] = new JniArgumentValue((displayMetrics == null) ? IntPtr.Zero : ((global::Java.Lang.Object)displayMetrics).Handle);
                var __rm = _members.StaticMethods.InvokeInt32Method(__id, __args);
                return(__rm);
            } finally {
            }
        }
 public static float GetDpi(this global::Android.App.Activity activity)
 {
     var metrics = new global::Android.Util.DisplayMetrics ();
     activity.WindowManager.DefaultDisplay.GetMetrics (metrics);
     return metrics.Xdpi;
 }
Ejemplo n.º 5
0
 public static int ConvertPixelsToDp(this global::Android.Util.DisplayMetrics @this, float pixelValue)
 {
     return((int)(pixelValue / @this.Density));
 }