[Android] AppCompat NavigationBar should handle Transluscent Flags (#1287)
* AppCompat NavigationBar handle Transluscent Flags * Handle padding on Navigationbar when rotated if the app uses any TransluscentFlags padding will be added to the Toolbar. When device is rotated a new height is calculated. This leads to the Toolbar being reset by ResetToolbar(). If the old toolbar was adjusted by toppadding the new toolbar should get the same padding to not be layout out under the statusbar
This commit is contained in:
Родитель
8ede382d02
Коммит
8ee768ce5f
|
@ -38,6 +38,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
|
|||
ActionBarDrawerToggle _drawerToggle;
|
||||
FragmentManager _fragmentManager;
|
||||
int _lastActionBarHeight = -1;
|
||||
int _statusbarHeight;
|
||||
AToolbar _toolbar;
|
||||
ToolbarTracker _toolbarTracker;
|
||||
DrawerMultiplexedListener _drawerListener;
|
||||
|
@ -396,6 +397,14 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
|
|||
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) || ((Activity)Context).Window.Attributes.Flags.HasFlag(WindowManagerFlags.TranslucentNavigation))
|
||||
{
|
||||
if (_toolbar.PaddingTop == 0)
|
||||
_toolbar.SetPadding(0, GetStatusBarHeight(), 0, 0);
|
||||
|
||||
return actionBarHeight + GetStatusBarHeight();
|
||||
}
|
||||
|
||||
return actionBarHeight;
|
||||
}
|
||||
|
||||
|
@ -411,6 +420,18 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
|
|||
valueAnim.Start();
|
||||
}
|
||||
|
||||
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 AnimateArrowOut()
|
||||
{
|
||||
var icon = _toolbar.NavigationIcon as DrawerArrowDrawable;
|
||||
|
@ -606,6 +627,11 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
|
|||
_toolbar = null;
|
||||
|
||||
SetupToolbar();
|
||||
|
||||
// if the old toolbar had padding from transluscentflags, set it to the new toolbar
|
||||
if (oldToolbar.PaddingTop != 0)
|
||||
_toolbar.SetPadding(0, oldToolbar.PaddingTop, 0, 0);
|
||||
|
||||
RegisterToolbar();
|
||||
UpdateToolbar();
|
||||
UpdateMenu();
|
||||
|
|
Загрузка…
Ссылка в новой задаче