本文整理汇总了C#中Button.SetBackgroundDrawable方法的典型用法代码示例。如果您正苦于以下问题:C# Button.SetBackgroundDrawable方法的具体用法?C# Button.SetBackgroundDrawable怎么用?C# Button.SetBackgroundDrawable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Button
的用法示例。
在下文中一共展示了Button.SetBackgroundDrawable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDeviceSelectionItem
private Button CreateDeviceSelectionItem(Device moj)
{
Button button = new Button (this);
button.SetBackgroundDrawable(Resources.GetDrawable(Resource.Drawable.android_button));
button.SetMaxHeight (25);
button.Text = string.Format (moj.Name);
button.Tag = moj.Id;
button.Click += OnDeviceSelected;
return button;
}
示例2: CreateEventItem
private Button CreateEventItem(Event Event)
{
Button button = new Button (this);
button.SetBackgroundDrawable(Resources.GetDrawable(Resource.Drawable.android_button));
button.Text = string.Format ("Latest Tow Event");
button.Click += (sender, e) => {
LatLng latln = new LatLng (Event.Location.Lat, Event.Location.Lng);
map.MoveCamera (CameraUpdateFactory.NewLatLngZoom (latln, 15));
locationDialog.Hide ();
};
;
return button;
}
示例3: SetTheme
public static void SetTheme(Button button, FlatTheme theme, FlatUI.FlatTextAppearance textAppearance,
FlatUI.FlatFontFamily fontFamily, FlatUI.FlatFontWeight fontWeight, bool isFullFlat, int padding, int radius)
{
var bottom = 5;
float[] outerR = {radius, radius, radius, radius, radius, radius, radius, radius};
// creating normal state drawable
var normalFront = new ShapeDrawable(new RoundRectShape(outerR, null, null));
normalFront.Paint.Color = theme.LightAccentColor;
normalFront.SetPadding(padding, padding, padding, padding);
var normalBack = new ShapeDrawable(new RoundRectShape(outerR, null, null));
normalBack.Paint.Color = theme.BackgroundColor;
if (isFullFlat)
bottom = 0;
normalBack.SetPadding(0, 0, 0, bottom);
Drawable[] d = {normalBack, normalFront};
var normal = new LayerDrawable(d);
// creating pressed state drawable
var pressedFront = new ShapeDrawable(new RoundRectShape(outerR, null, null));
pressedFront.Paint.Color = theme.BackgroundColor;
var pressedBack = new ShapeDrawable(new RoundRectShape(outerR, null, null));
pressedBack.Paint.Color = theme.DarkAccentColor;
if (!isFullFlat)
pressedBack.SetPadding(0, 0, 0, 3);
Drawable[] d2 = {pressedBack, pressedFront};
var pressed = new LayerDrawable(d2);
// creating disabled state drawable
var disabledFront = new ShapeDrawable(new RoundRectShape(outerR, null, null));
disabledFront.Paint.Color = theme.VeryLightAccentColor;
var disabledBack = new ShapeDrawable(new RoundRectShape(outerR, null, null));
disabledBack.Paint.Color = theme.LightAccentColor;
if (!isFullFlat) disabledBack.SetPadding(0, 0, 0, padding);
Drawable[] d3 = {disabledBack, disabledFront};
var disabled = new LayerDrawable(d3);
var states = new StateListDrawable();
states.AddState(new []{ Android.Resource.Attribute.StatePressed, Android.Resource.Attribute.StateEnabled }, pressed);
states.AddState(new []{ Android.Resource.Attribute.StateFocused, Android.Resource.Attribute.StateEnabled }, pressed);
states.AddState(new []{ Android.Resource.Attribute.StateEnabled }, normal);
states.AddState(new []{-Android.Resource.Attribute.StateEnabled}, disabled);
button.SetBackgroundDrawable (states);
if (textAppearance == FlatUI.FlatTextAppearance.Dark)
button.SetTextColor(theme.DarkAccentColor);
else if (textAppearance == FlatUI.FlatTextAppearance.Light)
button.SetTextColor(theme.VeryLightAccentColor);
else
button.SetTextColor(Android.Graphics.Color.White);
var typeface = FlatUI.GetFont(button.Context, fontFamily, fontWeight);
if (typeface != null)
button.SetTypeface(typeface, Android.Graphics.TypefaceStyle.Normal);
}