Created extension for adjusting margins on entry fields for specific android API levels.

This commit is contained in:
Kyle Spearrin 2016-08-23 23:57:11 -04:00
parent a7ba21f2f9
commit 2262e1c4c2
4 changed files with 28 additions and 15 deletions

View File

@ -27,11 +27,7 @@ namespace Bit.App.Controls
stackLayout.Children.Add(Editor);
Tapped += FormEditorCell_Tapped;
if(Device.OS == TargetPlatform.Android)
{
Editor.Margin = new Thickness(-4, -2, -4, -10);
}
Editor.AdjustMarginsForDevice();
View = stackLayout;
}

View File

@ -84,21 +84,18 @@ namespace Bit.App.Controls
var deviceInfo = Resolver.Resolve<IDeviceInfoService>();
if(useLabelAsPlaceholder)
{
if(deviceInfo.Version == 21)
if(deviceInfo.Version < 21)
{
Entry.Margin = new Thickness(-9, 0);
}
else if(deviceInfo.Version == 21)
{
Entry.Margin = new Thickness(0, 4, 0, -4);
}
}
else
{
if(deviceInfo.Version == 21)
{
Entry.Margin = new Thickness(-4, -2, -4, -11);
}
else
{
Entry.Margin = new Thickness(-4, -7, -4, -11);
}
Entry.AdjustMarginsForDevice();
}
}

View File

@ -38,8 +38,8 @@ namespace Bit.App.Controls
if(Device.OS == TargetPlatform.Android)
{
stackLayout.Spacing = 0;
Picker.Margin = new Thickness(-4, -2, -4, -10);
}
Picker.AdjustMarginsForDevice();
Tapped += FormPickerCell_Tapped;

View File

@ -44,5 +44,25 @@ namespace Bit.App
entry.Focus();
}
}
public static void AdjustMarginsForDevice(this View view)
{
if(Device.OS == TargetPlatform.Android)
{
var deviceInfo = Resolver.Resolve<IDeviceInfoService>();
if(deviceInfo.Version < 21)
{
view.Margin = new Thickness(-12, -5, -12, -6);
}
else if(deviceInfo.Version == 21)
{
view.Margin = new Thickness(-4, -2, -4, -11);
}
else
{
view.Margin = new Thickness(-4, -7, -4, -11);
}
}
}
}
}