问题描述: 在Android 8.0以后在EditText控件上多了一种自动填充功能, 可以在手机的设置->输入->自动填充功能中打开或者关闭, 但此功能在8.0 TextInputLayout 嵌套 EditText 的情况下使用时会引发崩溃。
解决方案: 我们的项目中是重写了EditText, 为了使用特殊字体, 而我解决这个问题就直接重写了EditText的getAutofillType()方法, 就不会再出现自动填充的选项了, 具体代码如下:
@Override
public int getAutofillType() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
//禁止EditText自动填充
return AUTOFILL_TYPE_NONE;
} else {
return super.getAutofillType();
}
}