本文整理汇总了C#中CheckBox.SetTextColor方法的典型用法代码示例。如果您正苦于以下问题:C# CheckBox.SetTextColor方法的具体用法?C# CheckBox.SetTextColor怎么用?C# CheckBox.SetTextColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CheckBox
的用法示例。
在下文中一共展示了CheckBox.SetTextColor方法的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: ChooseMultipleAsync
public Task<int[]> ChooseMultipleAsync(string message, string[] options, int[] selectedOptions, string title = null, string okButton = "OK", string cancelButton = "Cancel", TimeSpan? duration = null)
{
var tcs = new TaskCompletionSource<int[]>();
Application.SynchronizationContext.Post(ignored =>
{
if (this.CurrentActivity == null)
return;
var checkBoxes = options
.Select(x =>
{
var checkBox = new CheckBox(this.CurrentActivity)
{
LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)
{
Gravity = GravityFlags.CenterVertical
},
Gravity = GravityFlags.Center,
};
checkBox.SetTextColor(Color.White);
return checkBox;
})
.ToArray();
var optionLayouts = options
.Select((option, i) =>
{
var optionLayout = new LinearLayout(this.CurrentActivity)
{
LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent),
Orientation = Orientation.Horizontal
};
optionLayout.AddView(checkBoxes[i]);
optionLayout.AddView(new TextView(this.CurrentActivity)
{
LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent)
{
Gravity = GravityFlags.CenterVertical,
LeftMargin = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 8, CurrentActivity.Resources.DisplayMetrics)
},
Text = option
});
return optionLayout;
})
.ToArray();
var linearLayout = new LinearLayout(this.CurrentActivity)
{
LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent),
Orientation = Orientation.Vertical
};
foreach (var optionLayout in optionLayouts)
{
linearLayout.AddView(optionLayout);
}
var scrollView = new ScrollView(this.CurrentActivity)
{
LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent),
};
scrollView.AddView(linearLayout);
var builder = new AlertDialog.Builder(this.CurrentActivity)
.SetMessage(message)
.SetTitle(title)
.SetView(scrollView)
.SetPositiveButton(okButton, delegate
{
tcs.TrySetResult(options.Select((x, i) => ((checkBoxes[i].Checked) ? (i) : (-1))).Where(x => x != -1).ToArray());
})
.SetNegativeButton(cancelButton, delegate
{
tcs.TrySetResult(new int[0]);
});
var dialog = this.CustomizeAndCreate(builder);
dialog.Show();
if (duration.HasValue)
Task.Delay(duration.Value).ContinueWith((delayTask) => Application.SynchronizationContext.Post(ignored2 => dialog.SafeDismiss(), null));
}, null);
return tcs.Task;
}