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


C# EditText.SetTextAppearance方法代码示例

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


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

示例1: 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

示例2: AddFixedText

        public void AddFixedText(string text)
        {
            EditText fixedText = new EditText(Context);
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent);
            layoutParams.Gravity = GravityFlags.CenterVertical;
            fixedText.SetTextAppearance(Context, Resource.Style.judo_payments_CardText);
            fixedText.LayoutParameters = layoutParams;
            fixedText.Enabled = false;
            fixedText.Focusable = false;
            fixedText.Text = text;
            fixedText.SetBackgroundColor(Resources.GetColor(Android.Resource.Color.Transparent));
            fixedText.SetPadding(0,0,0,0);
            Typeface type = Typefaces.LoadTypefaceFromRaw(Context, Resource.Raw.courier);
            fixedText.Typeface = type;

            if (linearLayout.ChildCount > 1)
            {
                linearLayout.RemoveViewAt(0);
            }
            linearLayout.AddView(fixedText, 0);
        }
开发者ID:TheJaniceTong,项目名称:Judo-Xamarin,代码行数:21,代码来源:BackgroundHintTextView.cs


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