I'm having a problem on an specific device, the HTC EVO on Android 2.3.x. I think this may be a HTC Sense-specific problem.
I basically have an EditText
with a transparent background (#00000000) and white text, set to allow an email address input (inputType is textEmailAddress
).
Problem:When the user is writing the email address, however, text is black, thus impossible to read.
When the user changes focus to another view element, the text is correctly colored back to white.
If the user focuses back on the EditText
, the text previously entered is still white, but any new text is black.
If I change the inputType from textEmailAddress
, to say, nothing, or textFilter
, text is rendered correctly... it's still black, but it has a highlight around it (due to the "suggestions" provided by the keyboard - not shown on textEmailAddress
type.) and therefore, it's readable. The downside is not having the email input method (with "@" on the keyboard).
I'd like my text to just be always readable (that is, white when writing) and to have the proper (email) entry. Suggestions or not, it doesn't matter - it just has to be readable.
The EditText
used is simple enough:
<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 it's trying to "guess" the text color for selection highlight) and nothing works; there's no way to set the color of the text being written... it's always black.
I've experienced the same thing on some HTCs. I implemented a TextWatcher to force the text color as a Spannable as you type in the 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));