本文整理汇总了C#中CheckBox.SetPadding方法的典型用法代码示例。如果您正苦于以下问题:C# CheckBox.SetPadding方法的具体用法?C# CheckBox.SetPadding怎么用?C# CheckBox.SetPadding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CheckBox
的用法示例。
在下文中一共展示了CheckBox.SetPadding方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetTheme
public static void SetTheme(CheckBox checkBox, 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);
InsetDrawable 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);
checkBox.SetButtonDrawable(states);
// setting padding for avoiding text to be appear on icon
checkBox.SetPadding(size / 4 * 5, 0, 0, 0);
checkBox.SetTextColor(theme.LightAccentColor);
var typeface = FlatUI.GetFont(checkBox.Context, fontFamily, fontWeight);
if (typeface != null)
checkBox.SetTypeface(typeface, TypefaceStyle.Normal);
}
示例2: Initialize
void Initialize(KeyValuePair<object,object> title, bool selectedAlready)
{
this.Orientation = Orientation.Horizontal;
this.WeightSum = 1;
this.LayoutParameters = new ListView.LayoutParams(LayoutParams.MatchParent, PixelConverter.DpToPixels(40));
var text = new TextView(_context) { Text = (string)title.Key };
text.SetTextSize(Android.Util.ComplexUnitType.Dip, 20);
text.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.WrapContent, LayoutParams.MatchParent);
AddView(text);
var checkBoxPlacer = new LinearLayout(_context);
checkBoxPlacer.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
checkBoxPlacer.SetHorizontalGravity(GravityFlags.Right);
var checkbox = new CheckBox(_context);
if (selectedAlready)
checkbox.Checked = true;
checkbox.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.WrapContent, LayoutParams.MatchParent);
checkbox.SetPadding(0,0, PixelConverter.DpToPixels(15), 0);
checkBoxPlacer.AddView(checkbox);
checkbox.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) =>
{
Console.WriteLine(e.IsChecked);
if (ItemSelected != null)
ItemSelected(this, e);
};
AddView(checkBoxPlacer);
}