HTC Sense / EVO does not respect EditText color when recording

I have a problem with a specific device - HTC EVO on Android 2.3.x. I think this could be a HTC Sense issue.

I basically have an EditText with a transparent background (# 00000000) and white text allowing me to enter an email address (inputType - textEmailAddress ).

Problem: if the user writes an email address, the text is black, so it cannot be read.

When the user changes focus to another view element, the text is correctly colored white.

If the user accesses the EditText again, the previously entered text remains white, but any new text is black.

If I change the inputType from textEmailAddress , say nothing or textFilter , the text will display correctly ... it is still black, but it has a highlight around it (due to the "suggestions" provided by the keyboard - not shown on the textEmailAddress type.) and therefore it is readable. The downside does not have an email input method (with "@" on the keyboard).

I would like my text to be always readable (i.e. white when writing) and have the correct entry (email). Suggestions or not, it does not matter - it just has to be readable.

The used EditText quite simple:

 <EditText android:id="@+id/fieldEmail" android:layout_width="match_parent" android:layout_height="42dp" android:layout_marginTop="10dp" android:hint="Enter your email" android:textSize="16dp" android:textColor="#ffffffff" android:textColorHint="#ffffffff" android:textColorLink="#ffffffff" android:background="#00000000" android:inputType="textEmailAddress"> </EditText> 

Any suggestions? I tried several things, including changing all kinds of colors (in case he tries to "guess" the color of the text to highlight the selection), and nothing works; there is no way to set the color of the written text ... it is always black.

+4
source share
2 answers

I experienced the same thing on some HTC. I implemented TextWatcher to force the text color as Spannable when typing in EditText

  private class HTCEditTextFix implements TextWatcher { private EditText mEditText; public HTCEditTextFix(EditText editText) { mEditText = editText; } public void afterTextChanged(Editable s) {} public void beforeTextChanged(CharSequence s, int start, int count, int after) {} public void onTextChanged(CharSequence s, int start, int before, int count) { mEditText.getText().setSpan(new ForegroundColorSpan(Color.WHITE), start, start, Spannable.SPAN_COMPOSING); } } 

Then apply it to your EditText

 myEditText1.addTextChangedListener(new HTCEditTextFix(myEditText1)); 
+3
source

I would like to add a little comment here - using Spannable.SPAN_EXCLUSIVE_EXCLUSIVE in some cases can cause:

IndexOutOfBoundsException: setSpan(...

to avoid this, we just need to select a different span flag, Spannable.SPAN_COMPOSING works for me.

I got the mentioned exception when I edited the text in the EditText view and I received an incoming call. Also in a situation where I edited the text in the middle, and then I tried to add a character to the end (only on devices with HTC Sense <2.1).

+4
source

Source: https://habr.com/ru/post/1398882/


All Articles