本文整理汇总了C#中RadioButton.SetPadding方法的典型用法代码示例。如果您正苦于以下问题:C# RadioButton.SetPadding方法的具体用法?C# RadioButton.SetPadding怎么用?C# RadioButton.SetPadding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RadioButton
的用法示例。
在下文中一共展示了RadioButton.SetPadding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetTheme
public static void SetTheme(RadioButton radioButton, FlatTheme theme,
FlatUI.FlatFontFamily fontFamily, FlatUI.FlatFontWeight fontWeight, int radius, int size, int border)
{
// creating unchecked-enabled state drawable
GradientDrawable uncheckedEnabled = new GradientDrawable();
uncheckedEnabled.SetCornerRadius(radius);
uncheckedEnabled.SetSize(size, size);
uncheckedEnabled.SetColor(Color.Transparent);
uncheckedEnabled.SetStroke(border, theme.LightAccentColor);
// creating checked-enabled state drawable
GradientDrawable checkedOutside = new GradientDrawable();
checkedOutside.SetCornerRadius(radius);
checkedOutside.SetSize(size, size);
checkedOutside.SetColor(Color.Transparent);
checkedOutside.SetStroke(border, theme.LightAccentColor);
PaintDrawable checkedCore = new PaintDrawable(theme.LightAccentColor);
checkedCore.SetCornerRadius(radius);
checkedCore.SetIntrinsicHeight(size);
checkedCore.SetIntrinsicWidth(size);
var checkedInside = new InsetDrawable(checkedCore, border + 2, border + 2, border + 2, border + 2);
Drawable[] checkedEnabledDrawable = {checkedOutside, checkedInside};
LayerDrawable checkedEnabled = new LayerDrawable(checkedEnabledDrawable);
// creating unchecked-enabled state drawable
GradientDrawable uncheckedDisabled = new GradientDrawable();
uncheckedDisabled.SetCornerRadius(radius);
uncheckedDisabled.SetSize(size, size);
uncheckedDisabled.SetColor(Color.Transparent);
uncheckedDisabled.SetStroke(border, theme.VeryLightAccentColor);
// creating checked-disabled state drawable
GradientDrawable checkedOutsideDisabled = new GradientDrawable();
checkedOutsideDisabled.SetCornerRadius(radius);
checkedOutsideDisabled.SetSize(size, size);
checkedOutsideDisabled.SetColor(Color.Transparent);
checkedOutsideDisabled.SetStroke(border, theme.VeryLightAccentColor);
PaintDrawable checkedCoreDisabled = new PaintDrawable(theme.VeryLightAccentColor);
checkedCoreDisabled.SetCornerRadius(radius);
checkedCoreDisabled.SetIntrinsicHeight(size);
checkedCoreDisabled.SetIntrinsicWidth(size);
InsetDrawable checkedInsideDisabled = new InsetDrawable(checkedCoreDisabled, border + 2, border + 2, border + 2, border + 2);
Drawable[] checkedDisabledDrawable = {checkedOutsideDisabled, checkedInsideDisabled};
LayerDrawable checkedDisabled = new LayerDrawable(checkedDisabledDrawable);
StateListDrawable states = new StateListDrawable();
states.AddState(new int[]{-Android.Resource.Attribute.StateChecked, Android.Resource.Attribute.StateEnabled}, uncheckedEnabled);
states.AddState(new int[]{Android.Resource.Attribute.StateChecked, Android.Resource.Attribute.StateEnabled}, checkedEnabled);
states.AddState(new int[]{-Android.Resource.Attribute.StateChecked, -Android.Resource.Attribute.StateEnabled}, uncheckedDisabled);
states.AddState(new int[]{Android.Resource.Attribute.StateChecked, -Android.Resource.Attribute.StateEnabled}, checkedDisabled);
radioButton.SetButtonDrawable(states);
// setting padding for avoiding text to be appear on icon
radioButton.SetPadding(size / 4 * 5, 0, 0, 0);
radioButton.SetTextColor(theme.LightAccentColor);
var typeface = FlatUI.GetFont(radioButton.Context, fontFamily, fontWeight);
if (typeface != null)
radioButton.SetTypeface(typeface, TypefaceStyle.Normal);
}