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


C# EditText.SetTypeface方法代码示例

本文整理汇总了C#中EditText.SetTypeface方法的典型用法代码示例。如果您正苦于以下问题:C# EditText.SetTypeface方法的具体用法?C# EditText.SetTypeface怎么用?C# EditText.SetTypeface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EditText的用法示例。


在下文中一共展示了EditText.SetTypeface方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StyleTextField

        public static void StyleTextField( EditText textField, string placeholderText, string font, uint size )
        {
            textField.Background = null;
            textField.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor ) );

            textField.Hint = placeholderText;
            textField.SetHintTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor ) );

            textField.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( font ), TypefaceStyle.Normal );
            textField.SetTextSize( Android.Util.ComplexUnitType.Dip, size );
        }  
开发者ID:Higherbound,项目名称:HBMobileApp,代码行数:11,代码来源:ControlStyling.cs

示例2: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource.
            SetContentView (Resource.Layout.Main);

            editText = FindViewById<EditText> (Resource.Id.editText);
            Button validateButton = FindViewById<Button> (Resource.Id.validateButton);
            resultLabel = FindViewById<DecodeTextView> (Resource.Id.resultLabel);

            editText.KeyListener = Android.Text.Method.DigitsKeyListener.GetInstance("0123456789" + System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalDigits);

            validateButton.Click += OnNumberEntryCompleted;

            editText.SetTypeface(typeFaceRegular, TypefaceStyle.Normal);
            validateButton.SetTypeface(typeFaceRegular, TypefaceStyle.Normal);
            resultLabel.SetTypeface(typeFaceRegular, TypefaceStyle.Normal);

            //			editText.KeyPress += (object sender, View.KeyEventArgs e) => {
            //				e.Handled = false;
            //
            //				if (e.Event.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter) {
            //					var entry = editText;
            //					var resultText = "";
            //
            //					if (Mod10Check (entry.Text)) {
            //						resultText = "__VALID NUMBER";
            //					} else {
            //						resultText = "INVALID NUMBER";
            //					}
            //
            //					resultLabel.AnimateText (true, resultText, 10);
            //
            //					e.Handled = true;
            //				}
            //			};
        }
开发者ID:jonathanzuniga,项目名称:ValidateCreditCardNumber_Android,代码行数:38,代码来源:MainActivity.cs

示例3: SetTheme

		public static void SetTheme(EditText editText, FlatTheme theme, 
			FlatUI.FlatFontFamily fontFamily, FlatUI.FlatFontWeight fontWeight, FlatUI.FlatTextAppearance textAppearance,
			int style, int radius, int padding, int border)
		{
			float[] outerR = new float[]{radius, radius, radius, radius, radius, radius, radius, radius};

			// creating normal state drawable
			var normalFront = new ShapeDrawable(new RoundRectShape(outerR, null, null));
			normalFront.SetPadding(padding, padding, padding, padding);

			var normalBack = new ShapeDrawable(new RoundRectShape(outerR, null, null));
			normalBack.SetPadding(border, border, border, border);

			if (style == 0) {             // flat
				normalFront.Paint.Color = Color.Transparent;
				normalBack.Paint.Color = theme.LightAccentColor;
				editText.SetTextColor(theme.VeryLightAccentColor);

			} else if (style == 1) {      // box
				normalFront.Paint.Color = Color.White;
				normalBack.Paint.Color = theme.LightAccentColor;
				editText.SetTextColor(theme.BackgroundColor);

			} else if (style == 2) {      // transparent
				normalFront.Paint.Color = Color.Transparent;
				normalBack.Paint.Color = Color.Transparent;
				editText.SetTextColor(theme.BackgroundColor);
			}

			Drawable[] d = {normalBack, normalFront};
			LayerDrawable normal = new LayerDrawable(d);

			editText.SetBackgroundDrawable(normal);

			editText.SetHintTextColor(theme.VeryLightAccentColor);

			if (textAppearance == FlatUI.FlatTextAppearance.Dark) editText.SetTextColor(theme.DarkAccentColor);
			else if (textAppearance == FlatUI.FlatTextAppearance.Light) editText.SetTextColor(theme.VeryLightAccentColor);

			var typeface = FlatUI.GetFont(editText.Context, fontFamily, fontWeight);
			if (typeface != null)
				editText.SetTypeface(typeface, TypefaceStyle.Normal);
		}
开发者ID:kuruminbr,项目名称:FlatUI.Xamarin.Android,代码行数:43,代码来源:FlatEditText.cs

示例4: Init

        private void Init()
        {
            base.RemoveAllViews();

            hintTextView = new EditText(Context);
            textTextView = new NoCursorMovingEditText(Context, BackKeyPressed);

            linearLayout = new LinearLayout(Context);
            linearLayout.LayoutParameters = new ViewGroup.LayoutParams(LinearLayout.LayoutParams.MatchParent, (int)GetContainerHeight());

            textLayout = new RelativeLayout(Context);
            textLayout.LayoutParameters = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MatchParent, 1);
            textLayout.SetGravity(GravityFlags.Center);

            linearLayout.AddView(textLayout);

            textTextView.SetTextAppearance(Context, Resource.Style.judo_payments_CardText);
            hintTextView.SetTextAppearance(Context, Resource.Style.judo_payments_HintText);

            LayoutParams lp = new LayoutParams(LinearLayout.LayoutParams.MatchParent,
                LinearLayout.LayoutParams.WrapContent);
            lp.AddRule(LayoutRules.CenterVertical);

            hintTextView.LayoutParameters = lp;
            textTextView.LayoutParameters = lp;
            hintTextView.Enabled = false;
            hintTextView.Focusable = false;

            textTextView.InputType = InputTypes.ClassNumber | InputTypes.TextFlagNoSuggestions;
            hintTextView.InputType = InputTypes.ClassNumber | InputTypes.TextFlagNoSuggestions;

            hintTextView.SetBackgroundColor(Resources.GetColor(Android.Resource.Color.Transparent));
            textTextView.SetBackgroundColor(Resources.GetColor(Android.Resource.Color.Transparent));
            int horizontalPadding =
                Resources.GetDimensionPixelOffset(Resource.Dimension.backgroundhinttextview_horizontal_padding);
            hintTextView.SetPadding(horizontalPadding, 0 , horizontalPadding, 0);
            textTextView.SetPadding(horizontalPadding, 0, horizontalPadding, 0);

            textErrorView = new EditText(Context);
            RelativeLayout.LayoutParams errorLP = new RelativeLayout.LayoutParams(LayoutParams.MatchParent,
                LayoutParams.WrapContent);
            errorLP.AddRule(LayoutRules.CenterVertical);

            int margin = UiUtils.ToPixels(Context, 2);
            errorLP.SetMargins(margin, 0, margin, 0);

            textErrorView.LayoutParameters = errorLP;
            textErrorView.Enabled = false;
            textErrorView.Focusable = false;
            textErrorView.Visibility = ViewStates.Gone;
            textErrorView.SetBackgroundColor(Color.Red);
            int errorVerticalPadding =
                Context.Resources.GetDimensionPixelOffset(
                    Resource.Dimension.backgroundhinttextview_error_vertical_padding);
            textErrorView.SetPadding(horizontalPadding, errorVerticalPadding, horizontalPadding, errorVerticalPadding);
            textErrorView.Text = errorText;
            textErrorView.SetSingleLine(true);
            textErrorView.Gravity = GravityFlags.Center;
            textErrorView.SetTextAppearance(Context, Resource.Style.judo_payments_ErrorText);

            //set courier font
            Typeface type = Typefaces.LoadTypefaceFromRaw(Context, Resource.Raw.courier);
            //hintTextView.Typeface = type;
            hintTextView.SetTypeface(Typeface.Monospace, TypefaceStyle.Normal);
            //textTextView.Typeface = type;
            textTextView.SetTypeface(Typeface.Monospace, TypefaceStyle.Normal);
            textErrorView.Typeface = type;


            textLayout.AddView(hintTextView);
            textLayout.AddView(textTextView);

            AddView(linearLayout);

            IEnumerable<char> previousCharSequence;
            EventHandler<TextChangedEventArgs> beforeTextChanged = (sender, args) =>
                                                                    {
                                                                        previousCharSequence = args.Text;
                                                                    };

            EventHandler<TextChangedEventArgs> textChanged = (sender, args) =>
                                                            {
                                                                beforeTextSize = args.BeforeCount;
                                                            };

            EventHandler<AfterTextChangedEventArgs> afterTextChanged = null;

            
            Action<string> updateTextView = newText =>
            {
                textTextView.TextChanged -= textChanged;
                textTextView.BeforeTextChanged -= beforeTextChanged;
                textTextView.AfterTextChanged -= afterTextChanged;

                textTextView.Text = newText;

                textTextView.TextChanged += textChanged;
                textTextView.BeforeTextChanged += beforeTextChanged;
                textTextView.AfterTextChanged += afterTextChanged;
            };
//.........这里部分代码省略.........
开发者ID:TheJaniceTong,项目名称:Judo-Xamarin,代码行数:101,代码来源:BackgroundHintTextView.cs


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