зеркало из https://github.com/DeGsoft/maui-linux.git
ContextCompat.getColor if API < 23 (#5450)
Update Xamarin.Forms.Platform.Android/Forms.cs Does this do all the suggestions? Co-Authored-By: kingces95 <kingces95@users.noreply.github.com> ContextCompat.getColor if API < 23
This commit is contained in:
Родитель
7d5c0dc334
Коммит
92ffeb324f
|
@ -30,6 +30,7 @@ namespace Xamarin.Forms
|
|||
const int TabletCrossover = 600;
|
||||
|
||||
static bool? s_isLollipopOrNewer;
|
||||
static bool? s_isMarshmallowOrNewer;
|
||||
|
||||
[Obsolete("Context is obsolete as of version 2.5. Please use a local context instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
|
@ -55,6 +56,16 @@ namespace Xamarin.Forms
|
|||
}
|
||||
}
|
||||
|
||||
internal static bool IsMarshmallowOrNewer
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!s_isMarshmallowOrNewer.HasValue)
|
||||
s_isMarshmallowOrNewer = (int)Build.VERSION.SdkInt >= 23;
|
||||
return s_isMarshmallowOrNewer.Value;
|
||||
}
|
||||
}
|
||||
|
||||
public static Color GetColorButtonNormal(Context context)
|
||||
{
|
||||
if (!_ColorButtonNormalSet)
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using Android.Content;
|
||||
using Android.Support.V4.Content;
|
||||
using AColor = Android.Graphics.Color;
|
||||
using AColorRes = Android.Resource.Color;
|
||||
using Android.Views;
|
||||
|
||||
namespace Xamarin.Forms.Platform.Android
|
||||
|
@ -117,7 +120,9 @@ namespace Xamarin.Forms.Platform.Android
|
|||
bool isDefaultBkgndColor = bkgndColor.IsDefault;
|
||||
if (page.Parent is BaseShellItem && isDefaultBkgndColor)
|
||||
{
|
||||
var color = Context.Resources.GetColor(global::Android.Resource.Color.BackgroundLight, Context.Theme);
|
||||
var color = Forms.IsMarshmallowOrNewer ?
|
||||
Context.Resources.GetColor(AColorRes.BackgroundLight, Context.Theme) :
|
||||
new AColor(ContextCompat.GetColor(Context, global::Android.Resource.Color.BackgroundLight));
|
||||
SetBackgroundColor(color);
|
||||
}
|
||||
else if (!isDefaultBkgndColor || setBkndColorEvenWhenItsDefault)
|
||||
|
|
Загрузка…
Ссылка в новой задаче