public void Init(Context context, IAttributeSet attrs) { try { //Setup image attributes MImgSource = new FilterImageView(context); MImgSource.Id = ImgSrcId; MImgSource.SetAdjustViewBounds(true); LayoutParams imgSrcParam = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); imgSrcParam.AddRule(LayoutRules.CenterInParent, ImgSrcId); if (attrs != null) { //TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.NiceArtEditorView); //Drawable imgSrcDrawable = a.GetDrawable(Resource.Styleable.NiceArtEditorView_photo_src); //if (imgSrcDrawable != null) //{ // MImgSource.SetImageDrawable(imgSrcDrawable); //} } //Setup brush view MBrushDrawingView = new BrushDrawingView(context); MBrushDrawingView.Visibility = ViewStates.Gone; MBrushDrawingView.Id = BrushSrcId; //Align brush to the size of image view LayoutParams brushParam = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); brushParam.AddRule(LayoutRules.CenterInParent, ImgSrcId); brushParam.AddRule(LayoutRules.AlignTop, ImgSrcId); brushParam.AddRule(LayoutRules.AlignBottom, ImgSrcId); //Setup GLSurface attributes MImageFilterView = new ImageFilterView(context) { Id = GlFilterId, Visibility = ViewStates.Gone }; //Align brush to the size of image view LayoutParams imgFilterParam = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); imgFilterParam.AddRule(LayoutRules.CenterInParent, ImgSrcId); imgFilterParam.AddRule(LayoutRules.AlignTop, ImgSrcId); imgFilterParam.AddRule(LayoutRules.AlignBottom, ImgSrcId); OnBitmapLoaded(MImgSource.GetBitmap()); //Add image source AddView(MImgSource, imgSrcParam); //Add Gl FilterView AddView(MImageFilterView, imgFilterParam); //Add brush view AddView(MBrushDrawingView, brushParam); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private void layoutInvasion() { LayoutParams layoutParams = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); if (mNavigationView.Landscape) { switch (mInvasionFlag) { case FLAG_INVASION_STATUS: layoutParams.AddRule(Android.Widget.LayoutRules.LeftOf, Resource.Id.navigation_view); BringChildToFront(mStatusView); break; case FLAG_INVASION_NAVIGATION: layoutParams.AddRule(Android.Widget.LayoutRules.Below, Resource.Id.status_view); layoutParams.AddRule(Android.Widget.LayoutRules.LeftOf, Resource.Id.navigation_view); BringChildToFront(mNavigationView); break; case FLAG_INVASION_STATUS_AND_NAVIGATION: layoutParams.AddRule(Android.Widget.LayoutRules.LeftOf, Resource.Id.navigation_view); BringChildToFront(mStatusView); BringChildToFront(mNavigationView); break; case FLAG_NOT_INVASION: layoutParams.AddRule(Android.Widget.LayoutRules.Below, Resource.Id.status_view); layoutParams.AddRule(Android.Widget.LayoutRules.LeftOf, Resource.Id.navigation_view); break; } } else { switch (mInvasionFlag) { case FLAG_INVASION_STATUS: layoutParams.AddRule(Android.Widget.LayoutRules.Above, Resource.Id.navigation_view); BringChildToFront(mStatusView); break; case FLAG_INVASION_NAVIGATION: layoutParams.AddRule(Android.Widget.LayoutRules.Below, Resource.Id.status_view); BringChildToFront(mNavigationView); break; case FLAG_INVASION_STATUS_AND_NAVIGATION: BringChildToFront(mStatusView); BringChildToFront(mNavigationView); break; case FLAG_NOT_INVASION: layoutParams.AddRule(Android.Widget.LayoutRules.Below, Resource.Id.status_view); layoutParams.AddRule(Android.Widget.LayoutRules.Above, Resource.Id.navigation_view); break; } } mContentLayout.LayoutParameters = layoutParams; }
LayoutParams CreateLayout() { var result = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); result.AddRule(LayoutRules.AlignParentTop); result.AddRule(LayoutRules.AlignParentBottom); result.AddRule(LayoutRules.AlignParentLeft); result.AddRule(LayoutRules.AlignParentRight); return(result); }
private void InitImageIcon() { if (!_hasIcon) { return; } ImageView icon = new ImageView(Context); var lParams = new LayoutParams((int)Resources.GetDimension(Resource.Dimension.chip_height), (int)Resources.GetDimension(Resource.Dimension.chip_height)); lParams.AddRule(Build.VERSION.SdkInt >= BuildVersionCodes.JellyBeanMr1 ? LayoutRules.AlignParentStart : LayoutRules.AlignParentLeft); icon.LayoutParameters = lParams; icon.SetScaleType(ImageView.ScaleType.FitCenter); icon.Id = ChipUtils.IMAGE_ID; if (_chipIcon != null) { if (_chipIcon is BitmapDrawable bitmapDrawable && bitmapDrawable.Bitmap != null) { Bitmap bitmap = ((BitmapDrawable)_chipIcon).Bitmap; bitmap = ChipUtils.GetSquareBitmap(bitmap); bitmap = ChipUtils.GetScaledBitmap(Context, bitmap); icon.SetImageBitmap(ChipUtils.GetCircleBitmap(Context, bitmap)); } else { icon.SetImageDrawable(_chipIcon); } }
private ViewGroup CreateVideoView(SurfaceView surface) { try { RelativeLayout layout = new RelativeLayout(Context) { Id = surface.GetHashCode() }; LayoutParams videoLayoutParams = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); layout.AddView(surface, videoLayoutParams); TextView text = new TextView(Context) { Id = layout.GetHashCode() }; LayoutParams textParams = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); textParams.AddRule(LayoutRules.AlignParentBottom, 1); textParams.BottomMargin = MStatMarginBottom; textParams.LeftMargin = StatLeftMargin; text.SetTextColor(Color.White); text.SetTextSize(ComplexUnitType.Sp, StatTextSize); layout.AddView(text, textParams); return(layout); } catch (Exception e) { Methods.DisplayReportResultTrack(e); return(null); } }
public LoadingView(Context context, string message) : base(context) { LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); LinearLayout layout = new LinearLayout(context); ProgressBar pBar = new ProgressBar(context); pBar.Indeterminate = true; layout.AddView(pBar); if (message != null) { TextView text = new TextView(context); text.Text = message; text.TextSize = 18; text.Gravity = GravityFlags.CenterVertical; text.SetPadding(Utils.DpToPx(4), 0, 0, 0); layout.AddView(text, new LayoutParams(LayoutParams.WrapContent, LayoutParams.MatchParent)); } var lp = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); lp.AddRule(LayoutRules.CenterInParent); AddView(layout, lp); }
private void InitCloseImage() { if (!_closable) { return; } var lParams = new LayoutParams((int)Resources.GetDimension(Resource.Dimension.chip_close_icon_size_medium), (int)Resources.GetDimension(Resource.Dimension.chip_close_icon_size_medium)); lParams.AddRule(Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean ? LayoutRules.EndOf : LayoutRules.RightOf, ChipUtils.TEXT_ID); lParams.AddRule(LayoutRules.CenterVertical); lParams.SetMargins((int)Resources.GetDimension(Resource.Dimension.chip_close_horizontal_margin), 0, (int)Resources.GetDimension(Resource.Dimension.chip_close_horizontal_margin), 0); closeImageView.LayoutParameters = lParams; closeImageView.SetScaleType(ImageView.ScaleType.Center); closeImageView.SetImageDrawable(_closeIcon); ChipUtils.SetIconColor(closeImageView, _closeColor); InitCloseClick(); AddView(closeImageView); }
protected override void OnConfigurationChanged(Configuration newConfig) { if (mNavigationView.Landscape) { LayoutParams navigationParams = (LayoutParams)mNavigationView.LayoutParameters; navigationParams.AddRule(Android.Widget.LayoutRules.AlignParentRight); LayoutParams statusParams = (LayoutParams)mStatusView.LayoutParameters; statusParams.AddRule(Android.Widget.LayoutRules.AlignParentTop); statusParams.AddRule(Android.Widget.LayoutRules.LeftOf, Resource.Id.navigation_view); } else { LayoutParams statusParams = (LayoutParams)mStatusView.LayoutParameters; statusParams.AddRule(Android.Widget.LayoutRules.AlignParentTop); LayoutParams navigationParams = (LayoutParams)mNavigationView.LayoutParameters; navigationParams.AddRule(Android.Widget.LayoutRules.AlignParentBottom); } layoutInvasion(); }
private void Initialize() { ImageView logo = new ImageView(Context) { Id = 0x0fffff2a }; logo.SetImageResource(Resource.Drawable.logo); logo.SetAdjustViewBounds(true); logo.SetMinimumHeight(60); logo.SetMaxHeight(60); _imageCategoryView = new ImageView(Context); _imageCategoryView.SetAdjustViewBounds(true); _imageCategoryView.SetMinimumHeight(60); _imageCategoryView.SetMaxHeight(60); _imageCategoryView.Id = 0x0fffff2b; _imageCategoryView.SetMinimumWidth(60); _imageCategoryView.SetMaxWidth(60); _imageCategoryView.Measure(60, 60); _textCategoryView = new TextView(Context); _textCategoryView.SetMaxHeight(60); _textCategoryView.SetTextColor(Color.Black); _textCategoryView.Id = 0x0fffff2c; _textCategoryView.SetTextSize(ComplexUnitType.Sp, 15); _textCategoryView.Gravity = GravityFlags.CenterVertical; LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); lp.AddRule(LayoutRules.AlignParentRight); lp.AddRule(LayoutRules.CenterVertical); AddView(logo, lp); lp = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); lp.AddRule(LayoutRules.AlignParentLeft); lp.AddRule(LayoutRules.CenterVertical); AddView(_imageCategoryView, lp); lp = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); lp.AddRule(LayoutRules.RightOf, _imageCategoryView.Id); lp.AddRule(LayoutRules.CenterVertical); lp.SetMargins(60, 0, 60, 0); AddView(_textCategoryView, lp); }
public void AddAction(int colorId, int drawableId, Action onClick) { var newFab = new FloatingActionButton(Context); newFab.UseCompatPadding = true; var layoutParams = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); layoutParams.AddRule(LayoutRules.AlignParentBottom); layoutParams.AddRule(LayoutRules.AlignParentRight); newFab.LayoutParameters = layoutParams; newFab.Size = FloatingActionButton.SizeNormal; newFab.Visibility = ViewStates.Invisible; newFab.SetBackgroundColor(new Color(ContextCompat.GetColor(Context, colorId))); newFab.SetImageDrawable(ContextCompat.GetDrawable(Context, drawableId)); newFab.Click += (sender, e) => { onClick?.Invoke(); }; container.AddView(newFab, 0); fabs.Add(newFab); }
private void Init(Context context, IAttributeSet attrs = null) { ClipToOutline = true; //Elevation = TypedValue.ApplyDimension(ComplexUnitType.Dip, 18, context.Resources.DisplayMetrics); var layoutParams = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); layoutParams.AddRule(LayoutRules.CenterInParent); _imageView = new MvxCachedImageView(context) { LayoutParameters = layoutParams }; AddView(_imageView); }
public FormTheme(Context context, string title) : base(context) { LayoutParams thisLayoutParameters = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); LayoutParameters = thisLayoutParameters; TextView descriptionText = new TextView(Application.Context); ImageView indicatorImage = new ImageView(Application.Context); ImageButton infoButton = new ImageButton(Application.Context); LinearLayout descriptionHolder = new LinearLayout(Application.Context); descriptionHolder.Orientation = Orientation.Horizontal; descriptionText.Text = title; descriptionText.SetPadding(0, 20, 0, 0); descriptionText.SetTextColor(Color.ParseColor(context.Resources.GetString(Resource.Color.green_primary))); infoButton.SetImageResource(Resource.Drawable.form_info); infoButton.SetBackgroundResource(0); LayoutParams helpParameters = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); infoButton.LayoutParameters = helpParameters; descriptionHolder.AddView(descriptionText); descriptionHolder.AddView(infoButton); indicatorImage.SetPadding(50, 20, 0, 0); LayoutParams indicatorParameters = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); indicatorParameters.AddRule(LayoutRules.AlignParentRight); indicatorImage.LayoutParameters = indicatorParameters; AddView(descriptionHolder); AddView(indicatorImage); }
private void AddSearchBox() { _searchBox = new EditText(Context) { Id = this.GetGeneratedId() }; var layout = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent) { AlignWithParent = true, BottomMargin = 6 }; layout.AddRule(LayoutRules.AlignParentTop); _searchBox.LayoutParameters = layout; _searchBox.SetPadding(0, 0, 0, 6); AddView(_searchBox); _searchBox.TextChanged += OnTextChanged; }
private void DrawTags() { if (!mInitialized) { return; } // clear all tag RemoveAllViews(); // layout padding left & layout padding right float total = PaddingLeft + PaddingRight; int listIndex = 1; // List Index int indexBottom = 1; // The Tag to add below int indexHeader = 1; // The header tag of this line Tag tagPre = null; foreach (Tag item in mTags) { int position = listIndex - 1; Tag tag = item; LinearLayout tagLayout = new LinearLayout(mContext); tagLayout.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); tagLayout.SetGravity(GravityFlags.CenterVertical); tagLayout.Orientation = Android.Widget.Orientation.Horizontal; tagLayout.Id = listIndex; TextView tagView = new TextView(mContext); tagView.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); tagView.Gravity = GravityFlags.Center; tagView.Ellipsize = Android.Text.TextUtils.TruncateAt.End; tagView.SetSingleLine(true); TextView deletableView = new TextView(mContext); deletableView.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); deletableView.Gravity = GravityFlags.Center; deletableView.SetSingleLine(true); deletableView.Visibility = ViewStates.Gone; tagLayout.AddView(tagView); tagLayout.AddView(deletableView); if (Build.VERSION.SdkInt < BuildVersionCodes.JellyBean) { tagLayout.Background = GetSelector(tag); //.SetBackgroundDrawable(getSelector(tag)); } else { tagLayout.Background = GetSelector(tag); //.SetBackground(getSelector(tag)); } // tag text tagView.SetText(tag.Text, BufferType.Normal); LinearLayout.LayoutParams parametros = (LinearLayout.LayoutParams)tagView.LayoutParameters; parametros.SetMargins(textPaddingLeft, textPaddingTop, textPaddingRight, textPaddingBottom); tagView.LayoutParameters = parametros; tagView.SetTextColor(ColorStateList.ValueOf(new Color(tag.TagTextColor))); tagView.SetTextSize(ComplexUnitType.Sp, tag.TagTextSize); tagLayout.Click += delegate { if (mClickListener != null) { mClickListener.OnTagClick(tag, position); } }; tagLayout.LongClick += delegate { if (mTagLongClickListener != null) { mTagLongClickListener.OnTagLongClick(tag, position); } }; // calculate of tag layout width float tagWidth = tagView.Paint.MeasureText(tag.Text) + textPaddingLeft + textPaddingRight; // tagView padding (left & right) // deletable text= if (tag.IsDeletable) { deletableView.Visibility = ViewStates.Visible; deletableView.SetText(tag.DeleteIcon, BufferType.Normal); int offset = Utils.DipToPx(Application.Context, 2f); deletableView.SetPadding(offset, textPaddingTop, textPaddingRight + offset, textPaddingBottom); deletableView.SetTextColor(ColorStateList.ValueOf(new Color(tag.DeleteIndicatorColor))); deletableView.SetTextSize(ComplexUnitType.Sp, tag.DeleteIndicatorSize); deletableView.Click += delegate { if (mDeleteListener != null) { mDeleteListener.OnTagDeleted(this, tag, position); } }; tagWidth += deletableView.Paint.MeasureText(tag.DeleteIcon) + textPaddingLeft + textPaddingRight; // deletableView Padding (left & right) } else { deletableView.Visibility = ViewStates.Gone; } LayoutParams tagParams = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); //add margin of each line tagParams.BottomMargin = lineMargin; if (mWidth <= total + tagWidth + Utils.DipToPx(Application.Context, Constants.LAYOUT_WIDTH_OFFSET)) { //need to add in new line if (tagPre != null) { tagParams.AddRule(LayoutRules.Below, indexBottom); } // initialize total param (layout padding left & layout padding right) total = PaddingLeft + PaddingRight; indexBottom = listIndex; indexHeader = listIndex; } else { //no need to new line tagParams.AddRule(LayoutRules.AlignTop, indexHeader); //not header of the line if (listIndex != indexHeader) { tagParams.AddRule(LayoutRules.RightOf, listIndex - 1); tagParams.LeftMargin = tagMargin; total += tagMargin; if (tagPre.TagTextSize < tag.TagTextSize) { indexBottom = listIndex; } } } total += tagWidth; AddView(tagLayout, tagParams); tagPre = tag; listIndex++; } }
private void Initialize() { Id = _viewId; _maxNumberOfIndiagrams = LazyResolver<IScreenService>.Service.Width / IndiagramView.DefaultWidth - 1; ISettingsService settings = LazyResolver<ISettingsService>.Service; ColorStringToIntConverter colorConverter = new ColorStringToIntConverter(); // Init views for (int i = 0; i < _maxNumberOfIndiagrams; ++i) { IndiagramView view = new IndiagramView(Context) { TextColor = (uint) colorConverter.Convert(settings.TextColor, null, null, null), Id = _viewId++, DefaultColor = 0, }; view.Touch += OnIndiagramTouched; var layoutParams = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); layoutParams.AddRule(LayoutRules.CenterVertical); if (i == 0) { layoutParams.AddRule(LayoutRules.AlignParentLeft); } else { layoutParams.AddRule(LayoutRules.RightOf, _viewId - 2); } AddView(view, layoutParams); _indiagramViews.Add(view); } // Init play button _playButton = new IndiagramView(Context) { TextColor = 0, Id = _viewId++, Indiagram = new Indiagram() { Text = "play", ImagePath = LazyResolver<IStorageService>.Service.ImagePlayButtonPath } }; _playButton.Touch += (sender, args) => { if (args.Event.ActionMasked == MotionEventActions.Up){ if(args.Event.RawX<(LazyResolver<IScreenService>.Service.Width/4.0)){ if (CorrectionCommand != null && CorrectionCommand.CanExecute(null)) { CorrectionCommand.Execute(null); } } else if (ReadCommand != null && ReadCommand.CanExecute(null)) { ReadCommand.Execute(null); } } }; var lp = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); lp.AddRule(LayoutRules.AlignParentRight); lp.AddRule(LayoutRules.CenterVertical); AddView(_playButton, lp); }
private void InitLayout(IAttributeSet attrs, Context context) { if (attrs == null) { throw new Exception("You need to set attribut with this component <SectionBarLayout>"); } if (context == null) { throw new Exception("You need to set context for <SectionBarLayout>"); } _context = context; // placeholder de l'EditText var titleAttributArray = _context.ObtainStyledAttributes(attrs, Resource.Styleable.ImageEditTextLayout); var titleValue = titleAttributArray.GetString(Resource.Styleable.ImageEditTextLayout_textPlaceholder); // image de l'EditText var imageAttributArray = _context.ObtainStyledAttributes(attrs, Resource.Styleable.ImageEditTextLayout); var imageValue = imageAttributArray.GetResourceId(Resource.Styleable.ImageEditTextLayout_imageEditText, 0); // size du text de l'edit text var sizeTextAttributeArray = _context.ObtainStyledAttributes(attrs, Resource.Styleable.ImageEditTextLayout); var sizeTextValue = sizeTextAttributeArray.GetResourceId(Resource.Styleable.ImageEditTextLayout_imageEditTextSize, 0); // layout de l'image var imageLayout = new RelativeLayout(_context); imageLayout.LayoutParameters = new RelativeLayout.LayoutParams(AccessResources.Instance.SizeOf60Dip(), AccessResources.Instance.SizeOf60Dip()); imageLayout.SetBackgroundColor(AccessResources.Instance.ColorLayoutBackgroundSecondary()); imageLayout.Clickable = true; // initialisation de l'EditText EditText = new EditText(Context); EditText.SetTextColor(AccessResources.Instance.ColorTextColorContent()); EditText.SetHintTextColor(AccessResources.Instance.ColorTextColorHint()); EditText.SetTextSize(ComplexUnitType.Dip, 16); EditText.Hint = titleValue; EditText.SetPadding(0, 2, 0, 0); EditText.InputType = Android.Text.InputTypes.TextVariationUri; EditText.SetBackgroundResource(Resource.Drawable.EditTextParameterTemplate); EditText.Focusable = true; var titleTextParam = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); titleTextParam.AddRule(LayoutRules.CenterVertical); titleTextParam.SetMargins(AccessResources.Instance.SizeOf70Dip(), 0, 0, 0); EditText.LayoutParameters = titleTextParam; // image SVG var imageButtonSvgImage = new XamSvg.SvgImageView(_context, attrs); imageButtonSvgImage.SetSvg(_context, imageValue, string.Empty, string.Empty); var imageButtonParam = new LayoutParams(AccessResources.Instance.SizeOf30Dip(), AccessResources.Instance.SizeOf30Dip()); imageButtonParam.AddRule(LayoutRules.CenterInParent); imageButtonSvgImage.LayoutParameters = imageButtonParam; imageLayout.Click += ((o, e) => { EditText.SetSelection(EditText.Text.Length); EditText.RequestFocus(); InputMethodManager imm = (InputMethodManager)_context.GetSystemService(Context.InputMethodService); imm.ShowSoftInput(EditText, InputMethodManager.ShowImplicit); }); // ajout du titre dans la vue AddView(EditText); imageLayout.AddView(imageButtonSvgImage); AddView(imageLayout); }
void Initialize(Dictionary <string, QuestionGroup> questionGroups, string questionGroupName, int questionNumber, int savedAnswer) { QuestionGroups = questionGroups; QuestionGroupName = questionGroupName; QuestionNumber = questionNumber; BgColor = new Color(int.Parse(QuestionGroups[QuestionGroupName].Background, NumberStyles.AllowHexSpecifier | NumberStyles.HexNumber)); SetBackgroundColor(BgColor); rbGroup = (RadioGroup)LayoutInflater.From(Context).Inflate(Resource.Layout.questionGroup, this, false); var lpg = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); lpg.AddRule(LayoutRules.CenterInParent); AddView(rbGroup, lpg); var question = questionGroups[questionGroupName].Questions[questionNumber]; var txtQuestionNumber = new TextView(Context) { Text = $"{QuestionNumber+1} / {QuestionGroups[QuestionGroupName].Questions.Count}", TextSize = 16, Id = 18 }; txtQuestionNumber.SetPaddingRelative(0, 20, 0, 20); txtQuestionNumber.SetTextColor(Color.Black); var lpqn = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); lpqn.AddRule(LayoutRules.AlignParentTop); lpqn.AddRule(LayoutRules.CenterHorizontal); AddView(txtQuestionNumber, lpqn); var txtQuestion = new TextView(Context) { Text = question.Text, TextSize = 20 }; txtQuestion.SetTextSize(ComplexUnitType.Dip, 26); txtQuestion.SetTextColor(Color.Black); txtQuestion.SetTypeface(Typeface.DefaultBold, TypefaceStyle.Bold); var lpt = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); lpt.AddRule(LayoutRules.CenterHorizontal); lpt.AddRule(LayoutRules.Below, 18); AddView(txtQuestion, lpt); var answers = question.Answers; for (var i = 0; i < answers.Count; i++) { var rbEntry = (RadioButton)LayoutInflater.From(Context).Inflate(Resource.Layout.questionEntry, this, false); rbEntry.Checked = false; rbEntry.Id = i; rbEntry.Text = $"{answers[i].Text}"; rbEntry.CheckedChange += RbEntry_CheckedChange; rbGroup.AddView(rbEntry); if (i == savedAnswer) { rbEntry.Checked = true; } } var btn = new Button(Context) { Text = Resources.GetString(Resource.String.SubmitQuestion) + " ", Background = null, Visibility = QuestionNumber < QuestionGroups[QuestionGroupName].Questions.Count - 1? ViewStates.Gone : ViewStates.Visible }; btn.SetTextSize(ComplexUnitType.Dip, 20); btn.SetCompoundDrawablesWithIntrinsicBounds(0, 0, Resource.Drawable.Submit, 0); btn.Touch += Btn_Touch; var lpb = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); lpb.AddRule(LayoutRules.AlignParentRight); lpb.AddRule(LayoutRules.CenterVertical); AddView(btn, lpb); var buttonBar = new RelativeLayout(Context); buttonBar.SetBackgroundColor(Color.White); var buttonBarLP = new LayoutParams(LayoutParams.MatchParent, 110); buttonBarLP.AddRule(LayoutRules.AlignParentBottom); AddView(buttonBar, buttonBarLP); var btnPrev = new Button(Context) { Text = " " + Resources.GetString(Resource.String.PrevQuestion), TextSize = 14, Background = null, Visibility = QuestionNumber == 0 ? ViewStates.Gone : ViewStates.Visible }; btnPrev.SetTextSize(ComplexUnitType.Dip, 20); btnPrev.Click += BtnPrev_Click; var prevArrow = Resources.GetDrawable(Resource.Drawable.Prev); prevArrow.Bounds = new Rect(0, 0, 51, 51); btnPrev.SetCompoundDrawables(prevArrow, null, null, null); var lpbp = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); lpbp.AddRule(LayoutRules.AlignParentLeft); lpbp.AddRule(LayoutRules.CenterVertical); buttonBar.AddView(btnPrev, lpbp); var btnNext = new Button(Context) { Text = Resources.GetString(Resource.String.NextQuestion) + " ", TextSize = 14, Background = null, Visibility = QuestionNumber >= QuestionGroups[QuestionGroupName].Questions.Count - 1 ? ViewStates.Gone : ViewStates.Visible }; btnNext.SetTextSize(ComplexUnitType.Dip, 20); btnNext.Click += BtnNext_Click; var nextArrow = Resources.GetDrawable(Resource.Drawable.Next); nextArrow.Bounds = new Rect(0, 0, 51, 51); btnNext.SetCompoundDrawables(null, null, nextArrow, null); var lpbn = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); lpbn.AddRule(LayoutRules.AlignParentRight); lpbn.AddRule(LayoutRules.CenterVertical); buttonBar.AddView(btnNext, lpbn); var btnMenu = new Button(Context) { Text = Resources.GetString(Resource.String.BackToMainMenu) + " ", TextSize = 14, Background = null }; btnMenu.SetTextSize(ComplexUnitType.Dip, 20); btnMenu.Click += BtnMenu_Click; var lpbb = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); lpbb.AddRule(LayoutRules.CenterInParent); //lpbb.AddRule(LayoutRules.CenterVertical); buttonBar.AddView(btnMenu, lpbb); }
public LoadingOverlay(Context context, bool withoutSpinner = false, PriceGrabber.CustomControls.Orientation orientation = PriceGrabber.CustomControls.Orientation.Portrait) : base(context) { Color mainColor = Color.LightBlue; try { mainColor = ((Xamarin.Forms.Color)Xamarin.Forms.Application.Current.Resources["LightBlue"]).ToAndroid(); } catch { } this.Alpha = 0.75f; this.SetBackgroundColor(mainColor); var contentHeight = (int)StaticDeviceInfo.Height; var contentWidth = (int)StaticDeviceInfo.Width; if (orientation == PriceGrabber.CustomControls.Orientation.Landscape) { contentHeight = contentHeight + contentWidth; contentWidth = contentHeight - contentWidth; contentHeight = contentHeight - contentWidth; } // SetMinimumWidth(contentWidth); //SetMinimumHeight(contentHeight); this.LayoutParameters = new ViewGroup.LayoutParams(-1, -1); LayoutParams lp; image = new ImageView(this.Context); // image.SetImageResource(Resource.Drawable.insigniaStar); image.SetMinimumHeight(contentHeight / 2); image.SetMinimumWidth(contentWidth / 2); lp = new LayoutParams(contentHeight / 2, contentWidth / 2); lp.AddRule(LayoutRules.CenterInParent); AddView(image, lp); spinner = new ProgressBar(this.Context); if (Build.VERSION.SdkInt >= BuildVersionCodes.M) { spinner.SetForegroundGravity(GravityFlags.CenterVertical | GravityFlags.CenterHorizontal); } spinner.SetMinimumWidth(100); spinner.SetPadding(0, 0, 0, 50); spinner.IndeterminateDrawable.SetColorFilter(Color.White, PorterDuff.Mode.SrcIn); lp = new LayoutParams(100, 150); lp.AddRule(LayoutRules.CenterInParent); /*ViewGroup.LayoutParams vlp = new ViewGroup.LayoutParams( * ViewGroup.LayoutParams.MatchParent, * ViewGroup.LayoutParams.MatchParent);*/ if (!withoutSpinner && spinner.Parent == null) { AddView(spinner, lp); } label = new TextView(this.Context); // { Text = HPHData.LocalizableText("Loading data") }; label.Gravity = GravityFlags.Center; label.SetPadding(0, 100, 0, 0); label.SetTextColor(Color.White); label.SetText("Loading data", TextView.BufferType.Normal); try { var tf = Typeface.CreateFromAsset(MainActivity.Instance.Assets, "HPSimplified_Lt.ttf"); label.SetTypeface(tf, TypefaceStyle.Normal); } catch { } lp = new LayoutParams(300, 150); lp.AddRule(LayoutRules.CenterInParent); if (!withoutSpinner && label.Parent == null) { AddView(label, lp); } }
protected void Init(Context context, IAttributeSet attrs) { if (IsInEditMode) { return; } if (null == attrs) { throw new IllegalArgumentException("Attributes should be provided to this view,"); } TypedArray typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.RippleBackground); rippleColor = typedArray.GetColor(Resource.Styleable.RippleBackground_rb_rippleColour, -1); rippleStrokeWidth = typedArray.GetDimension(Resource.Styleable.RippleBackground_rb_strokeWidth, Resource.Dimension.rippleStrokeWidth); rippleRadius = typedArray.GetDimension(Resource.Styleable.RippleBackground_rb_radius, Resource.Dimension.rippleRadius); rippleDurationTime = typedArray.GetInt(Resource.Styleable.RippleBackground_rb_duration, DEFAULT_DURATION_TIME); rippleAmount = typedArray.GetInt(Resource.Styleable.RippleBackground_rb_rippleAmount, DEFAULT_RIPPLE_COUNT); rippleScale = typedArray.GetFloat(Resource.Styleable.RippleBackground_rb_scale, DEFAULT_SCALE); rippleType = typedArray.GetInt(Resource.Styleable.RippleBackground_rb_type, DEFAULT_FILL_TYPE); RippleOnClick = typedArray.GetBoolean(Resource.Styleable.RippleBackground_rb_rippleOnClick, true); typedArray.Recycle(); rippleDelay = rippleDurationTime / rippleAmount; paint = new Paint { AntiAlias = true }; if (rippleType == DEFAULT_FILL_TYPE) { rippleStrokeWidth = 0; paint.SetStyle(Paint.Style.Fill); } else { paint.SetStyle(Paint.Style.Stroke); } // set colour if (rippleColor == -1) { paint.Color = Color.DarkBlue; } else { paint.Color = new Color(rippleColor); } rippleParams = new LayoutParams((int)(2 * (rippleRadius + rippleStrokeWidth)), (int)(2 * (rippleRadius + rippleStrokeWidth))); rippleParams.AddRule(LayoutRules.CenterInParent, 1); animatorSet = new AnimatorSet(); animatorSet.SetInterpolator(new AccelerateDecelerateInterpolator()); animatorList = new JavaList <Animator>(); for (int i = 0; i < rippleAmount; i++) { RippleView rippleView = new RippleView(Context, rippleStrokeWidth, paint); AddView(rippleView, rippleParams); rippleViewList.Add(rippleView); ObjectAnimator scaleXAnimator = ObjectAnimator.OfFloat(rippleView, "ScaleX", 1.0f, rippleScale); scaleXAnimator.RepeatCount = ValueAnimator.Infinite; scaleXAnimator.RepeatMode = ValueAnimatorRepeatMode.Restart; scaleXAnimator.StartDelay = (i * rippleDelay); scaleXAnimator.SetDuration(rippleDurationTime); animatorList.Add(scaleXAnimator); ObjectAnimator scaleYAnimator = ObjectAnimator.OfFloat(rippleView, "ScaleY", 1.0f, rippleScale); scaleYAnimator.RepeatCount = ValueAnimator.Infinite; scaleYAnimator.RepeatMode = ValueAnimatorRepeatMode.Restart; scaleYAnimator.StartDelay = (i * rippleDelay); scaleYAnimator.SetDuration(rippleDurationTime); animatorList.Add(scaleYAnimator); ObjectAnimator alphaAnimator = ObjectAnimator.OfFloat(rippleView, "Alpha", 1.0f, 0f); alphaAnimator.RepeatCount = ValueAnimator.Infinite; alphaAnimator.RepeatMode = ValueAnimatorRepeatMode.Restart; alphaAnimator.StartDelay = (i * rippleDelay); alphaAnimator.SetDuration(rippleDurationTime); animatorList.Add(alphaAnimator); } // set up click event Click += RippleBackground_Click; animatorSet.PlayTogether(animatorList); }
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; }; afterTextChanged = (sender, args) => { var length = args.Editable.ToString().Length; var deleting = beforeTextSize == 1; if (deleting) { nextMustBeDeleted = false; } else { if (nextMustBeDeleted && length > 0) { updateTextView(args.Editable.SubSequence(0, length - 1)); UpdateHintTextForCurrentTextEntry(); return; } } // If we are deleting (we've just removed a space char, so delete another char please: // Or if we've pressed space don't allow it! if ((deleting && skipCharsAtPositions.Contains(length)) || (length > 0 && IsCharInFilter(args.Editable.CharAt(length - 1)) && !skipCharsAtPositions.Contains(length - 1))) { updateTextView(length == 0 ? "" : args.Editable.SubSequence(0, length - 1)); textTextView.SetSelection(length == 0 ? 0 : length - 1); UpdateHintTextForCurrentTextEntry(); return; } // Adds a non numeric char at positions needed for (int i = 0; i < skipCharsAtPositions.Count; ++i) { // We rescan all letters recursively to catch when a users pastes into the edittext int charPosition = skipCharsAtPositions[i]; if (length > charPosition) { if (hintText[charPosition] != args.Editable.ToString()[charPosition]) { updateTextView(args.Editable.SubSequence(0, charPosition) + "" + hintText[charPosition] + args.Editable.SubSequence(charPosition, args.Editable.Length())); UpdateHintTextForCurrentTextEntry(); return; } } else { if (length == charPosition) { updateTextView(textTextView.Text + "" + hintText[charPosition]); } } } UpdateHintTextForCurrentTextEntry(); // We've got all the chars we need, fire off our listener if (length >= LengthToStartValidation()) { try { ValidateInput(args.Editable.ToString()); if (OnEntryComplete != null) { OnEntryComplete(args.Editable.ToString()); } return; } catch (Exception exception) { Log.Error(JudoSDKManager.DEBUG_TAG, exception.Message, exception); } ShowInvalid(); } else { if (OnProgress != null) { OnProgress(length); } } }; textTextView.BeforeTextChanged += beforeTextChanged; textTextView.TextChanged += textChanged; textTextView.AfterTextChanged += afterTextChanged; }
private void Initialize() { _reinforcerView = new View(Context); LayoutParams param = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); param.AddRule(LayoutRules.CenterInParent); AddView(_reinforcerView, param); _indiagramView = new ImageView(Context); param = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); param.AddRule(LayoutRules.CenterInParent); AddView(_indiagramView, param); _indiagramView.SetImageResource(Resource.Drawable.root); }
private void AddProgressView() { _progressBar = new ProgressBar(Context); var layout = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) { TopMargin = 10 }; layout.AddRule(LayoutRules.Below, _searchBox.Id); layout.AddRule(LayoutRules.CenterHorizontal); _progressBar.LayoutParameters = layout; _progressBar.Indeterminate = true; AddView(_progressBar); }
public void SetupLayout(PdfView pdfView) { LayoutRules align; int width, height; Drawable background; // determine handler position, default is right (when scrolling vertically) or bottom (when scrolling horizontally) if (pdfView.IsSwipeVertical) { width = HandleLong; height = HandleShort; if (inverted) { // left align = LayoutRules.AlignParentLeft; background = Context.GetDrawable(Resource.Drawable.default_scroll_handle_left); } else { // right align = LayoutRules.AlignParentRight; background = Resources.GetDrawable(Resource.Drawable.default_scroll_handle_right); } } else { width = HandleShort; height = HandleLong; if (inverted) { // top align = LayoutRules.AlignParentTop; background = Context.GetDrawable(Resource.Drawable.default_scroll_handle_top); } else { // bottom align = LayoutRules.AlignParentBottom; background = Context.GetDrawable(Resource.Drawable.default_scroll_handle_bottom); } } if (Build.VERSION.SdkInt < BuildVersionCodes.JellyBean) { SetBackgroundDrawable(background); } else { Background = background; } var lp = new LayoutParams(Util.Util.GetDp(context, width), Util.Util.GetDp(context, height)); lp.SetMargins(0, 0, 0, 0); var tvlp = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); tvlp.AddRule(LayoutRules.CenterInParent); AddView(textView, tvlp); lp.AddRule(align); pdfView.AddView(this, lp); this.pdfView = pdfView; }
internal PickerInnerView(Context context, PickerAdapter adapter) : base(context) { LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); var padding = (int)context.ToPixels(8); SetPadding(padding, padding, padding, padding); SetBackgroundColor(adapter.BackgroundColor); _Title = new TextView(context) { Id = GenerateViewId() }; _Title.SetBackgroundColor(adapter.BackgroundColor); _Title.SetTextColor(adapter.TextColor); _Title.SetTextSize(ComplexUnitType.Sp, (float)adapter.FontSize); _Description = new TextView(context) { Id = GenerateViewId() }; _Description.SetBackgroundColor(adapter.BackgroundColor); _Description.SetTextColor(adapter.DetailColor); _Description.SetTextSize(ComplexUnitType.Sp, (float)adapter.DetailFontSize); _CheckBox = new SimpleCheck(context, adapter.AccentColor) { Focusable = false, }; _CheckBox.SetBackgroundColor(adapter.BackgroundColor); _CheckBox.SetHighlightColor(adapter.AccentColor); _Container = new LinearLayout(context) { Orientation = Orientation.Vertical }; _Container.SetBackgroundColor(adapter.BackgroundColor); using (var param = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)) { _Container.AddView(_Title, param); _Container.AddView(_Description, param); } using (var param = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)) { param.AddRule(LayoutRules.AlignParentStart); param.AddRule(LayoutRules.CenterVertical); AddView(_Container, param); } using (var param = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent) { Width = (int)context.ToPixels(30), Height = (int)context.ToPixels(30) }) { param.AddRule(LayoutRules.AlignParentEnd); param.AddRule(LayoutRules.CenterVertical); AddView(_CheckBox, param); } }
private void AddResultView() { _resultListView = new MvxListView(Context, _attrs); var layout = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); layout.AddRule(LayoutRules.Below, _searchBox.Id); _resultListView.LayoutParameters = layout; _resultListView.ItemClick = WrappedItemClickCommand; AddView(_resultListView); }
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.SetTypeface(Typeface.Monospace, TypefaceStyle.Normal); 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; }; afterTextChanged = (sender, args) => { var length = args.Editable.ToString().Length; var deleting = beforeTextSize == 1; if (deleting) { nextMustBeDeleted = false; } else { if (nextMustBeDeleted && length > 0) { updateTextView(args.Editable.SubSequence(0, length - 1)); UpdateHintTextForCurrentTextEntry(); return; } } // If we are deleting (we've just removed a space char, so delete another char please: // Or if we've pressed space don't allow it! if ((deleting && skipCharsAtPositions.Contains(length)) || (length > 0 && IsCharInFilter(args.Editable.CharAt(length - 1)) && !skipCharsAtPositions.Contains(length - 1))) { updateTextView(length == 0 ? "" : args.Editable.SubSequence(0, length - 1)); textTextView.SetSelection(length == 0 ? 0 : length - 1); UpdateHintTextForCurrentTextEntry(); return; } // Adds a non numeric char at positions needed for (int i = 0; i < skipCharsAtPositions.Count; ++i) { // We rescan all letters recursively to catch when a users pastes into the edittext int charPosition = skipCharsAtPositions [i]; if (length > charPosition) { if (hintText [charPosition] != args.Editable.ToString() [charPosition]) { updateTextView(args.Editable.SubSequence(0, charPosition) + "" + hintText [charPosition] + args.Editable.SubSequence(charPosition, args.Editable.Length())); UpdateHintTextForCurrentTextEntry(); return; } } else { if (length == charPosition) { updateTextView(textTextView.Text + "" + hintText [charPosition]); } } } UpdateHintTextForCurrentTextEntry(); // We've got all the chars we need, fire off our listener if (length >= LengthToStartValidation()) { try { ValidateInput(args.Editable.ToString()); if (OnEntryComplete != null) { OnEntryComplete(args.Editable.ToString()); } return; } catch (Exception exception) { Log.Error(JudoSDKManager.DEBUG_TAG, exception.Message, exception); } ShowInvalid(); } else { if (OnProgress != null) { OnProgress(length); } } }; textTextView.BeforeTextChanged += beforeTextChanged; textTextView.TextChanged += textChanged; textTextView.AfterTextChanged += afterTextChanged; }