Rock Lee
Rock Lee

Reputation: 9576

Android EditText weird floating white box under cursor

Update: I tried setting android:cursorVisible="false" on the EditText, and it made the white box go away but also made the blinking cursor & green circle go away too, but I want those to stay visible.


There's this weird white box under my cursor. Whenever I tap on the field, the large green circle (under the cursor, flashing | thing) shows up along with that white box underneath it. After several seconds, both the large green circle and the white box disappear. How do I get rid of that white box? I don't think I have anything in styles.xml changing things, except the primary and accent colors?

enter image description here


<EditText
                    android:id="@+id/altPhone"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/alt_phone_hint"
                    android:singleLine="true"
                    android:inputType="phone"
                    android:nextFocusDown="@+id/email"/>

mAltPhoneField.setText(person.getPhoneAlternate());

InputFilter[] phoneFilterArray = new InputFilter[2];
phoneFilterArray[0] = TextUtilities.getPhoneFilter();
phoneFilterArray[1] = new InputFilter.LengthFilter(14);
mAltPhoneField.setFilters(phoneFilterArray);

mAltPhoneField.addTextChangedListener(new PhoneNumberFormattingTextWatcher() {
            @Override
            public void afterTextChanged(Editable s) {
                super.afterTextChanged(s);
                mObj.getPerson().modifyPhoneAlternate(s.toString());
            }
        });

mAltPhoneField.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (!hasFocus) {
                    hasValidAltPhone();
                }
            }
        });

private boolean hasValidAltPhone() {
    return hasValidPhoneNumber(mAltPhoneField);
}

private boolean hasValidPhoneNumber(EditText field) {
        boolean isValidPhone = true;
        if (!TextUtils.isEmpty(field.getText())) {
            isValidPhone = TextUtilities.isValidPhoneNumber(field.getText().toString());
            if (!isValidPhone) {
                field.setError(getString(R.string.invalid_phone_error));
            }
        }
        return isValidPhone;
    }

Upvotes: 2

Views: 1188

Answers (1)

Rock Lee
Rock Lee

Reputation: 9576

In my styles.xml, I just had to remove the XML attribute for android:popupBackground, then the white box went away.

<resources>
    <style name="Theme.MyApp.Base" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:popupBackground">@android:drawable/dialog_holo_light_frame</item>
    </style>
</resources>

Upvotes: 3

Related Questions