Android 如何禁用TextInputLayout密码切换按钮的涟漪效应
我使用TextInputLayout显示密码切换按钮。它正在工作,但涟漪效应在EditText的背景后面(我使用EditText的可绘制背景)。如何禁用密码按钮的涟漪效应或将涟漪置于EditText背景前?这里是演示问题的录制视频Android 如何禁用TextInputLayout密码切换按钮的涟漪效应,android,xml,material-design,android-textinputlayout,material-components-android,Android,Xml,Material Design,Android Textinputlayout,Material Components Android,我使用TextInputLayout显示密码切换按钮。它正在工作,但涟漪效应在EditText的背景后面(我使用EditText的可绘制背景)。如何禁用密码按钮的涟漪效应或将涟漪置于EditText背景前?这里是演示问题的录制视频 删除文本输入文本中的android:background=“@drawable/bg_edit”并使用以下命令,可以获得相同的结果: 注意:app:passwordToggleEnabled=“true”不推荐使用。只需添加。这不是一个绝妙的解决方案,但它对我很有
删除
文本输入文本中的android:background=“@drawable/bg_edit”
并使用以下命令,可以获得相同的结果:
注意:app:passwordToggleEnabled=“true”
不推荐使用。只需添加。这不是一个绝妙的解决方案,但它对我很有效。
材料版本:1.1.0
科尔廷:
textInputLayout.apply {
findViewById<View>(R.id.text_input_end_icon).setBackgroundColor(
ResourcesCompat.getColor(resources, R.color.transparent, theme)
)
}
textInputLayout.apply{
findViewById(R.id.text\u input\u end\u图标)。setBackgroundColor(
ResourcesCompat.getColor(资源,R.color.transparent,主题)
)
}
R.id.text\u input\u end\u图标
通过布局检查器找到一种简单的方法,为密码切换创建一个新主题,如下所示。父主题是您的主(应用)主题
为什么要在EditText
中使用android:background=“@drawable/bg\u edit”
?发布您试图实现的布局。删除android:background并重试我需要表单外观的背景,因此无法删除它。我尝试了OutlinedBox样式,但它无法立即使用。这是edittext上的先看后看焦点和后看焦点。@Bagusajisanto所以不清楚。你必须删除文本输入文本中的背景。是的,我已经删除了背景,但是大纲框看起来没有对齐好。除了样式、约束和宽度/高度之外,我没有其他属性。
<com.google.android.material.textfield.TextInputLayout
android:hint="••••••"
app:endIconMode="password_toggle"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
app:boxBackgroundColor="@color/....."
..>
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:padding="18dp" />
</com.google.android.material.textfield.TextInputLayout>
textInputLayout.apply {
findViewById<View>(R.id.text_input_end_icon).setBackgroundColor(
ResourcesCompat.getColor(resources, R.color.transparent, theme)
)
}
<style name="PasswordToggleTransparent" parent="NoActionBar">
<item name="colorControlHighlight">#0000</item>
</style>