protected override void UpdateBackgroundColor()
		{
			if (_textInputLayout == null)
				return;

			_textInputLayout.BoxBackgroundColor = MaterialColors.CreateEntryFilledInputBackgroundColor(Element.BackgroundColor, Element.TextColor);
		}
Exemple #2
0
        void ApplyTheme()
        {
            if (_textInputLayout == null)
            {
                return;
            }

            // set text color
            var textColor = TextColor;

            UpdateTextColor(Color.FromUint((uint)textColor.ToArgb()));
            var colors = MaterialColors.CreateEntryUnderlineColors(textColor, textColor.WithAlpha(kFilledTextFieldOnSurfaceAlpha));

            // Ensure that we SetBackgroundTintList when focused to override the themes accent color which gets
            // applied to the underline
            if (_previousTextColor != textColor)
            {
                if (HasFocus)
                {
                    _previousTextColor = textColor;
                }

                ViewCompat.SetBackgroundTintList(_textInputEditText, colors);
            }

            // set placeholder color
            AColor placeholderColor;

            if (Element.PlaceholderColor == Color.Default)
            {
                if (Element.TextColor == Color.Default)
                {
                    placeholderColor = MaterialColors.Light.OnSurfaceColor;
                }
                else
                {
                    placeholderColor = textColor;
                }
            }
            else
            {
                placeholderColor = Element.PlaceholderColor.ToAndroid();
            }

            if (!HasFocus)
            {
                placeholderColor = placeholderColor.WithAlpha(kFilledTextFieldOnSurfaceAlpha + kFilledPlaceHolderOffset);
            }

            _textInputLayout.DefaultHintTextColor = MaterialColors.CreateEntryFilledPlaceholderColors(placeholderColor);
        }
		void ApplyTheme()
		{
			if (_textInputLayout == null)
				return;

			// set text color
			var textColor = MaterialColors.GetEntryTextColor(Element.TextColor);
			UpdateTextColor(Color.FromUint((uint)textColor.ToArgb()));

			var placeHolderColors = MaterialColors.GetPlaceHolderColor(Element.PlaceholderColor, Element.TextColor);
			var underlineColors = MaterialColors.GetUnderlineColor(Element.TextColor);

			var colors = MaterialColors.CreateEntryUnderlineColors(underlineColors.FocusedColor, underlineColors.UnFocusedColor);

			ViewCompat.SetBackgroundTintList(_textInputEditText, colors);

						
			if (HasFocus || !string.IsNullOrWhiteSpace(_textInputEditText.Text))
				_textInputLayout.DefaultHintTextColor = MaterialColors.CreateEntryFilledPlaceholderColors(placeHolderColors.FloatingColor, placeHolderColors.FloatingColor);
			else
				_textInputLayout.DefaultHintTextColor = MaterialColors.CreateEntryFilledPlaceholderColors(placeHolderColors.InlineColor, placeHolderColors.FloatingColor);
		}
        void ResetTextColors(Color formsTextColor, Color formsPlaceHolderColor)
        {
            _formsPlaceholderColor = formsPlaceHolderColor;
            _formsTextColor        = formsTextColor;

            var underlineColors   = MaterialColors.GetUnderlineColor(_formsTextColor);
            var placeHolderColors = MaterialColors.GetPlaceHolderColor(_formsPlaceholderColor, _formsTextColor);

            // I realize these are the same but I have to set it to a difference instance
            // otherwise when focused it won't change to the color I want it to and it'll just think
            // I'm not actually changing anything
            _unfocusedUnderlineColorsList = MaterialColors.CreateEntryUnderlineColors(underlineColors.FocusedColor, underlineColors.UnFocusedColor);
            _focusedUnderlineColorsList   = MaterialColors.CreateEntryUnderlineColors(underlineColors.FocusedColor, underlineColors.UnFocusedColor);

            _focusedFilledColorList  = MaterialColors.CreateEntryFilledPlaceholderColors(placeHolderColors.FloatingColor, placeHolderColors.FloatingColor);
            _unfocusedEmptyColorList = MaterialColors.CreateEntryFilledPlaceholderColors(placeHolderColors.InlineColor, placeHolderColors.FloatingColor);


            var textColor = MaterialColors.GetEntryTextColor(formsTextColor).ToArgb();

            EditText.SetTextColor(new ColorStateList(s_colorStates, new[] { textColor, textColor }));
        }
Exemple #5
0
        protected override void UpdateBackgroundColor()
        {
            if (_textInputLayout == null)
            {
                return;
            }

            if (Element.BackgroundColor == Color.Default)
            {
                if (Element.TextColor != Color.Default)
                {
                    _textInputLayout.BoxBackgroundColor = MaterialColors.CreateEntryFilledInputBackgroundColor(TextColor);
                }
                else
                {
                    _textInputLayout.BoxBackgroundColor = MaterialColors.CreateEntryFilledInputBackgroundColor(MaterialColors.Light.PrimaryColorVariant);
                }
            }
            else
            {
                _textInputLayout.BoxBackgroundColor = Element.BackgroundColor.ToAndroid();
            }
        }