Android自动填充忽略importantForAutofill="no"属性问题求助
Android自动填充异常(联系ID字段被错误填充)解决方案
检查
importantForAutofill设置层级
仅给内部TextInputEditText设置importantForAutofill="no"可能无效,需同时给外层TextInputLayout添加该属性,确保容器和输入框都被系统标记为无需自动填充:<com.google.android.material.textfield.TextInputLayout android:importantForAutofill="no" ...> <com.google.android.material.textfield.TextInputEditText android:importantForAutofill="no" ... /> </com.google.android.material.textfield.TextInputLayout>明确指定自动填充提示为
none
给联系ID字段添加android:autofillHints="none",进一步明确告知系统不要对该字段进行自动填充匹配:android:autofillHints="none"隔离自动填充组
将名字、姓氏字段归入同一autofillGroup,同时让联系ID字段独立于该组之外,避免系统错误关联字段:<!-- 姓名与姓氏字段 --> <com.google.android.material.textfield.TextInputLayout android:autofillGroup="name_group" ...> <com.google.android.material.textfield.TextInputEditText android:autofillHints="givenName" ... /> </com.google.android.material.textfield.TextInputLayout> <com.google.android.material.textfield.TextInputLayout android:autofillGroup="name_group" ...> <com.google.android.material.textfield.TextInputEditText android:autofillHints="familyName" ... /> </com.google.android.material.textfield.TextInputLayout> <!-- 联系ID字段 --> <com.google.android.material.textfield.TextInputLayout android:importantForAutofill="no" android:autofillHints="none" ...> <com.google.android.material.textfield.TextInputEditText android:importantForAutofill="no" android:autofillHints="none" ... /> </com.google.android.material.textfield.TextInputLayout>代码动态设置(兼容多版本)
若布局属性在部分Android版本不生效,可通过代码动态配置:contactIdEditText.importantForAutofill = View.IMPORTANT_FOR_AUTOFILL_NO contactIdEditText.autofillHints = arrayOf("none")
内容的提问来源于stack exchange,提问作者gabs
相关产品推荐
相关产品推荐

