You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除material.textfield.TextInputEditText(Material编辑框)的底部边框

问题原因

你给TextInputEditText设置透明背景无法生效,是因为Material组件库中,TextInputLayout才是控制输入框边框、提示样式的容器,默认自带的底部下划线是TextInputLayout的属性控制,而非子EditText的background属性。

解决方法

给你的TextInputLayout添加对应属性即可完全移除底部边框,修改后的完整代码如下:

<com.google.android.material.textfield.TextInputLayout
            android:layout_width="200dp"
            android:layout_height="50dp"
            android:layout_marginBottom="40dp"
            app:passwordToggleEnabled="true"
            app:boxStrokeWidth="0dp"
            app:boxStrokeWidthFocused="0dp"
            app:boxBackgroundMode="none">

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/register_password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textPassword"
                android:background="#00000000"
                android:textSize="14sp" />

</com.google.android.material.textfield.TextInputLayout>

你也可以选择给TextInputLayout指定无框样式style="@style/Widget.MaterialComponents.TextInputLayout.NoBox",和上面的属性设置效果一致。

内容的提问来源于stack exchange,提问作者AI Shakil

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.29 22:39:00