Ejemplo n.º 1
0
        private void Init()
        {
            SetMaxLines(1);
            Threshold = 0;

            ItemClick += OnItemClick;
            Adapter    = adapter = new SuggestCompleteAdapter(Context, Android.Resource.Layout.SimpleDropDownItem1Line);

            //
            //setba

            SetPadding(0, this.PaddingTop, this.PaddingRight, this.PaddingBottom);
            CompoundDrawablePadding = 25;

            Typeface tf = Typeface.CreateFromAsset(Android.App.Application.Context.Assets, "Poppins-Medium.ttf");

            this.SetTypeface(tf, TypefaceStyle.Normal);
            this.SetTextSize(Android.Util.ComplexUnitType.Dip, 14);

            this.SetHintTextColor(Android.Graphics.Color.ParseColor("#A7A7A7"));
            this.SetLinkTextColor(Android.Graphics.Color.Black);
            this.SetTextColor(Android.Graphics.Color.Black);
            this.SetBackgroundColor(Android.Graphics.Color.Transparent);

            // this.SetHighlightColor(Android.Graphics.Color.Black);
            // this.Background.SetColorFilter(Android.Graphics.Color.Black, PorterDuff.Mode.SrcAtop);

            var result = new Android.Text.InputTypes();

            result = InputTypes.ClassText | InputTypes.TextFlagNoSuggestions;

            this.InputType = result;
        }
Ejemplo n.º 2
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || e.NewElement == null)
            {
                return;
            }

            element = (PaketEntry)this.Element;

            Control.SetPadding(0, Control.PaddingTop, Control.PaddingRight, Control.PaddingBottom);

            var editText = this.Control;

            editText.SetHintTextColor(Android.Graphics.Color.ParseColor("#A7A7A7"));

            if (!string.IsNullOrEmpty(element.Image))
            {
                switch (element.ImageAlignment)
                {
                case ImageAlignment.Left:
                    editText.SetCompoundDrawablesWithIntrinsicBounds(GetDrawable(element.Image), null, null, null);
                    break;

                case ImageAlignment.Right:
                    editText.SetCompoundDrawablesWithIntrinsicBounds(null, null, GetDrawable(element.Image), null);
                    break;
                }
            }

            if (element.DisableAutoCorrect)
            {
                var result = new Android.Text.InputTypes();

                var capitalizedSentenceEnabled  = false;
                var capitalizedWordsEnabled     = false;
                var capitalizedCharacterEnabled = false;

                var spellcheckEnabled  = false;
                var suggestionsEnabled = false;


                if (element.CapSentences == 1)
                {
                    capitalizedWordsEnabled = true;
                }
                else if (element.CapSentences == 2)
                {
                }
                else
                {
                    capitalizedSentenceEnabled = true;
                }

                if (!capitalizedSentenceEnabled && !spellcheckEnabled && !suggestionsEnabled)
                {
                    result = InputTypes.ClassText | InputTypes.TextFlagNoSuggestions;
                }

                if (!capitalizedSentenceEnabled && !spellcheckEnabled && suggestionsEnabled)
                {
                    // Due to the nature of android, TextFlagAutoCorrect includes Spellcheck
                    result = InputTypes.ClassText | InputTypes.TextFlagAutoCorrect;
                }

                if (!capitalizedSentenceEnabled && spellcheckEnabled && !suggestionsEnabled)
                {
                    result = InputTypes.ClassText | InputTypes.TextFlagAutoComplete;
                }

                if (!capitalizedSentenceEnabled && spellcheckEnabled && suggestionsEnabled)
                {
                    result = InputTypes.ClassText | InputTypes.TextFlagAutoCorrect;
                }

                if (capitalizedSentenceEnabled && !spellcheckEnabled && !suggestionsEnabled)
                {
                    result = InputTypes.ClassText | InputTypes.TextFlagCapSentences | InputTypes.TextFlagNoSuggestions;
                }

                if (capitalizedSentenceEnabled && !spellcheckEnabled && suggestionsEnabled)
                {
                    // Due to the nature of android, TextFlagAutoCorrect includes Spellcheck
                    result = InputTypes.ClassText | InputTypes.TextFlagCapSentences | InputTypes.TextFlagAutoCorrect;
                }

                if (capitalizedSentenceEnabled && spellcheckEnabled && !suggestionsEnabled)
                {
                    result = InputTypes.ClassText | InputTypes.TextFlagCapSentences | InputTypes.TextFlagAutoComplete;
                }

                if (capitalizedSentenceEnabled && spellcheckEnabled && suggestionsEnabled)
                {
                    result = InputTypes.ClassText | InputTypes.TextFlagCapSentences | InputTypes.TextFlagAutoCorrect;
                }

                if (capitalizedWordsEnabled)
                {
                    result = result | InputTypes.TextFlagCapWords;
                }

                if (capitalizedCharacterEnabled)
                {
                    result = result | InputTypes.TextFlagCapCharacters;
                }

                editText.InputType = result;
            }
            else if (element.CapSentences == 1)
            {
                editText.SetRawInputType(Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextFlagCapWords);
            }
            else if (element.CapSentences == 2)
            {
                editText.SetRawInputType(Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextVariationEmailAddress);
            }

            editText.CompoundDrawablePadding = 25;


            Typeface tf = Typeface.CreateFromAsset(Android.App.Application.Context.Assets, "Poppins-Medium.ttf");

            editText.SetTypeface(tf, TypefaceStyle.Normal);
            editText.SetTextSize(Android.Util.ComplexUnitType.Dip, 14);

            if (element.BackgroundV == 0)
            {
                Control.Background = ContextCompat.GetDrawable(Context, Resource.Layout.EntryLayout);
            }
            else if (element.BackgroundV == 3 || element.BackgroundV == 4)
            {
                Control.Background = ContextCompat.GetDrawable(Context, Resource.Layout.EntryLayoutTransparent);

                //    if(element.BackgroundV==4)
                //    {
                //        Control.SetPadding(0, Control.PaddingTop, Control.PaddingRight, 0);
                //    }
            }
            else if (element.BackgroundV == 1)
            {
                Control.Background = ContextCompat.GetDrawable(Context, Resource.Layout.EntryLayoutGray);
            }
            else
            {
                Control.Background = ContextCompat.GetDrawable(Context, Resource.Layout.EntryLayoutLightGray);
            }
        }