Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //usage:
- // ContactGrid is the x:Name of the Grid within the ScrollView
- protected override void OnAppearing()
- {
- base.OnAppearing();
- ContactGrid.LayoutStars(((float)App.INSTANCE.Resources["PageHeight"]));
- }
- //In your MainActivity:
- private void InitAppResources()
- {
- App.INSTANCE.Resources["StatusBarHeight"] = GetStatusBarHeight() / Resources.DisplayMetrics.Density;
- App.INSTANCE.Resources["NavBarHeight"] = GetNavBarHeight() / Resources.DisplayMetrics.Density;
- App.INSTANCE.Resources["screenHeight"] = Resources.DisplayMetrics.HeightPixels / Resources.DisplayMetrics.Density;
- App.INSTANCE.Resources["screenWidth"] = Resources.DisplayMetrics.WidthPixels / Resources.DisplayMetrics.Density;
- App.INSTANCE.Resources["screenDensity"] = Resources.DisplayMetrics.Density;
- App.INSTANCE.Resources["PageHeight"] = (Resources.DisplayMetrics.HeightPixels - GetStatusBarHeight() - GetNavBarHeight()) / Resources.DisplayMetrics.Density;
- }
- private int GetNavBarHeight()
- {
- int resourceId = Resources.GetIdentifier("navigation_bar_height", "dimen", "android");
- if (resourceId > 0)
- {
- return Resources.GetDimensionPixelSize(resourceId);
- }
- return 0;
- }
- private int GetStatusBarHeight()
- {
- int resourceId = Resources.GetIdentifier("status_bar_height", "dimen", "android");
- if (resourceId > 0)
- {
- return Resources.GetDimensionPixelSize(resourceId);
- }
- return 0;
- }
- //In your AppDelegate:
- private void InitAppResources()
- {
- App.INSTANCE.Resources["statusBarHeight"] = (float)(40 / UIScreen.MainScreen.NativeScale);
- App.INSTANCE.Resources["navBarHeight"] = (float)(88 / UIScreen.MainScreen.NativeScale);
- App.INSTANCE.Resources["screenHeight"] = (float)(UIScreen.MainScreen.NativeBounds.Height / UIScreen.MainScreen.NativeScale);
- App.INSTANCE.Resources["screenWidth"] = (float)(UIScreen.MainScreen.NativeBounds.Width / UIScreen.MainScreen.NativeScale);
- App.INSTANCE.Resources["screenDensity"] = (float)UIScreen.MainScreen.NativeScale;
- App.INSTANCE.Resources["pageHeight"] = (float)((UIScreen.MainScreen.NativeBounds.Height - 40 - 88) / UIScreen.MainScreen.NativeScale);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement