Android EditText奇怪的浮动白框在光标下

时间:2016-09-19 23:42:26

标签: android android-edittext

更新 我尝试在EditText上设置android:cursorVisible="false",它使白框消失,但也使闪烁的光标和&绿色圆圈也消失了,但我希望它们能够保持可见。

我的光标下面有一个奇怪的白框。每当我点击该字段时,大的绿色圆圈(在光标下面,闪烁的东西)会显示在它下方的白色框中。几秒钟后,大绿色圆圈和白色框都消失了。我怎么摆脱那个白盒子?我不认为我在styles.xml中有什么改变,除了主色和强调色之外?

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;
    }

1 个答案:

答案 0 :(得分:2)

在我的styles.xml中,我只需删除android:popupBackground的XML属性,然后白框就消失了。

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