如何从EditText删除所有默认填充? [英] How can I remove all default padding from EditText?

查看:120
本文介绍了如何从EditText删除所有默认填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是EditText,它总是在我的文本中向左和向右添加一点填充.
添加android:includeFontPadding="false"并没有帮助,使用负数android:layout_marginLeftandroid:layout_marginRight只会使EditText扩展".
如何从默认添加的EditText中删除所有填充?

I am using an EditText and it always adds a bit of padding in my text to both left and right.
Adding android:includeFontPadding="false" did not help and using negative android:layout_marginLeft or android:layout_marginRight just makes the EditText "expand".
How can I strip all padding from the EditText that is being added by default?

<EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="20dp"
            android:fontFamily="roboto-regular"
            android:layout_gravity="center_vertical"
            android:gravity="center_vertical"
            android:layout_marginLeft="-5dp"
            android:layout_marginRight="-5dp"
            android:includeFontPadding="false"
            android:textSize="@dimen/size"
            android:textColor="@color/color"
            android:inputType="textCapWords"
            android:hint="@string/hint"
            android:editable="false"

            />

推荐答案

要删除EditText左右两侧的填充,可以使用以下命令:

To remove the padding on the left and right of the EditText, you can use the following:

<EditText
    ...
    android:paddingLeft="0dp"
    android:paddingRight="0dp"
    ... />

这篇关于如何从EditText删除所有默认填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆