using Android.Graphics.Drawables;
using Android.OS;
using Android.Views;
// ReSharper disable once CheckNamespace
namespace System
{
///
/// 对 类的扩展函数集
///
public static class ViewExtensions
{
///
/// Set the background to a given Drawable, or remove the background. If the background has padding, this View's padding is set to the background's padding. However, when a background is removed, this View's padding isn't touched. If setting the padding is desired, please use setPadding(int, int, int, int).
/// https://developer.android.google.cn/reference/android/view/View#setBackground(android.graphics.drawable.Drawable)
///
///
/// The Drawable to use as the background, or null to remove the background
public static void SetBackground(this View view, Drawable? background)
{
if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean)
{
view.Background = background;
}
else
{
#pragma warning disable CS0618 // 类型或成员已过时
view.SetBackgroundDrawable(background);
#pragma warning restore CS0618 // 类型或成员已过时
}
}
}
}