使用 TextInputLayout
包装 EditText
时,似乎自动添加了左侧填充,如下面的屏幕截图所示。
没有向布局 XML 中的 EditText
添加任何填充,但是当呈现 View 时,EditText
上似乎有左侧填充。在比较 TextInputLayout
下方的 TextView
时可以看到这一点。
如何禁止添加此左侧填充?
谢谢!
最佳答案
您可以将内部 EditText 上的开始和结束填充设置为 0dp。
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="0dp"
android:paddingEnd="0dp" />
</com.google.android.material.textfield.TextInputLayout>
这是带有 Show Layout Bounds 的屏幕截图打开,这样您就可以看到提示一直到 View 的边缘。
关于android - 如何禁用 TextInputLayout 上的填充?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41403193/