learn_andrd
learn_andrd

Reputation: 1046

How to get screen dimensions in Monoandroid?

How to get screen dimensions in Monoandroid ?

Android'd method doesn't work here. Please suggest.

Upvotes: 2

Views: 2238

Answers (1)

Mouna Cheikhna
Mouna Cheikhna

Reputation: 39638

try this :

 void ShowDimensions()
  {
   Display d = WindowManager.DefaultDisplay;
   string s = string.Format("{0}x{1} Orientation {2}\nRotation {3}\nPixelFmt {4}",
    d.Width, d.Height, d.Orientation, d.Rotation, d.PixelFormat );

   Android.Util.DisplayMetrics m = new Android.Util.DisplayMetrics();
   d.GetMetrics( m );

   s += string.Format("\n\n{0}x{1} dpiX {2}, dpiY {3}\nDensity{4}\nScaleDensity {5}\nDensity Dpi {6}",
    m.WidthPixels, m.HeightPixels, m.Xdpi, m.Ydpi, m.Density, m.ScaledDensity, m.DensityDpi);

   status.Text = s;
  }

Upvotes: 4

Related Questions