Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Android] make NavigationBar support Transluscent status #1116

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class NavigationPageRenderer : VisualElementRenderer<NavigationPage>, IMa
ActionBarDrawerToggle _drawerToggle;
FragmentManager _fragmentManager;
int _lastActionBarHeight = -1;
int _statusbarHeight;
AToolbar _toolbar;
ToolbarTracker _toolbarTracker;
DrawerMultiplexedListener _drawerListener;
Expand Down Expand Up @@ -387,8 +388,28 @@ int ActionBarHeight()
if (actionBarHeight <= 0)
return Device.Info.CurrentOrientation.IsPortrait() ? (int)Context.ToPixels(56) : (int)Context.ToPixels(48);

if (((Activity)Context).Window.Attributes.Flags.HasFlag(WindowManagerFlags.TranslucentStatus))
{
if (_toolbar.PaddingTop == 0)
_toolbar.SetPadding(0, GetStatusBarHeight(), 0, 0);

return actionBarHeight + GetStatusBarHeight();
}

return actionBarHeight;
}

int GetStatusBarHeight()
{
if (_statusbarHeight > 0)
return _statusbarHeight;

int resourceId = Resources.GetIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0)
_statusbarHeight = Resources.GetDimensionPixelSize(resourceId);

return _statusbarHeight;
}

void AnimateArrowIn()
{
Expand Down Expand Up @@ -906,4 +927,4 @@ public void OnDrawerStateChanged(int newState)
}
}
}
}
}