当前位置: 首页>>代码示例>>C#>>正文


C# Button.SetBackgroundDrawable方法代码示例

本文整理汇总了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;
 }
开发者ID:rockyhe,项目名称:MojioTowingAlert,代码行数:10,代码来源:MainMenuActivity.cs

示例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;
 }
开发者ID:rockyhe,项目名称:MojioTowingAlert,代码行数:13,代码来源:MainMenuActivity.cs

示例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);
		}
开发者ID:kuruminbr,项目名称:FlatUI.Xamarin.Android,代码行数:67,代码来源:FlatButton.cs


注:本文中的Button.SetBackgroundDrawable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。