如何禁用TextInputLayout上的填充? [英] How to disable padding on TextInputLayout?
问题描述
使用TextInputLayout
包裹EditText
时似乎会自动添加左侧填充,如下面的屏幕截图所示.
There appears to be left padding automatically added when using a TextInputLayout
to wrap an EditText
as you can see in the screenshot below.
在布局XML中的EditText
中没有添加任何填充,但是在渲染视图时,在EditText
上似乎保留了填充.在比较TextInputLayout
下的TextView
时,您会看到这一点.
There is no padding added to the EditText
in the layout XML, but when the view is rendered there appears to be left padding on the EditText
. You can see this when comparing the TextView
below the TextInputLayout
.
如何禁止添加此左填充?
How do I disable this left padding from being added?
谢谢!
推荐答案
TextInputLayout
是LinearLayout
,因此您应该能够指定负的边距或填充,例如
TextInputLayout
is a LinearLayout
, so you should be able to specify a negative margin or padding, e.g.
android:layout_marginLeft="-2dp"
android:layout_marginStart="-2dp"
这将抵消您要消除的空间.
that will offset the space you're trying to eliminate.
-2dp
值只是一个猜测;调整值,直到它符合您想要的方式.
The -2dp
value is just a guess; tune the value until it lines up the way you want.
这篇关于如何禁用TextInputLayout上的填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!