本文整理汇总了C#中RadioButton.SetTextColor方法的典型用法代码示例。如果您正苦于以下问题:C# RadioButton.SetTextColor方法的具体用法?C# RadioButton.SetTextColor怎么用?C# RadioButton.SetTextColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RadioButton
的用法示例。
在下文中一共展示了RadioButton.SetTextColor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChooseSingleAsync
public Task<int?> ChooseSingleAsync(string message, string[] options, int? chosenItem, 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 radioButtons = options
.Select((option, i) =>
{
var checkBox = new RadioButton(this.CurrentActivity)
{
LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)
{
Gravity = GravityFlags.CenterVertical
},
Id = (i + 1),
Text = option,
Gravity = GravityFlags.Center,
};
checkBox.SetTextColor(Color.White);
return checkBox;
})
.ToArray();
var radioGroup = new RadioGroup(this.CurrentActivity)
{
LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent),
Orientation = Orientation.Vertical
};
foreach (var optionLayout in radioButtons)
{
radioGroup.AddView(optionLayout);
}
var scrollView = new ScrollView(this.CurrentActivity)
{
LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent),
};
scrollView.AddView(radioGroup);
var builder = new AlertDialog.Builder(this.CurrentActivity)
.SetMessage(message)
.SetTitle(title)
.SetView(scrollView)
.SetPositiveButton(okButton, delegate
{
tcs.TrySetResult((radioGroup.CheckedRadioButtonId > 0) ? (radioGroup.CheckedRadioButtonId - 1) : ((int?)null));
})
.SetNegativeButton(cancelButton, delegate
{
tcs.TrySetResult(null);
});
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;
}
示例2: 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);
}