Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

How to retrieve the width and height exposed to the Grid?

$
0
0

I want to divide a grid in three equal (absolute) horizontal parts.

For instance: three parts.

My idea would be that of creating Column definitions that have an absolute width of one third of Application.Context.Resources.DisplayMetrics.WidthPixels.

So,

int DeviceWidth= Application.Context.Resources.DisplayMetrics.WidthPixels;
new ColumnDefinition {Width = new GridLength(DeviceWidth/3, GridUnitType.Absolute) }, //0
new ColumnDefinition {Width = new GridLength(DeviceWidth/3, GridUnitType.Absolute) }, //1
new ColumnDefinition {Width = new GridLength(DeviceWidth/3, GridUnitType.Absolute) }, //2

However, with a Google Nexus 4.4.2, this makes the cells HUGE.

The only way to have this working is using one SIXTH

new ColumnDefinition {Width = new GridLength(DeviceWidth/6, GridUnitType.Absolute) }, //0
new ColumnDefinition {Width = new GridLength(DeviceWidth/6, GridUnitType.Absolute) }, //1
new ColumnDefinition {Width = new GridLength(DeviceWidth/6, GridUnitType.Absolute) }, //2

I guess this means that the double density comes into play?

How to retrieve the real widths and hieghts that the device exposes to the views?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>