Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remove all default padding from 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"

            />
like image 660
Jim Avatar asked Aug 18 '15 20:08

Jim


People also ask

How do I remove the default padding in Textinputlayout?

You can just set the start and end padding on the inner EditText to 0dp. Here's a screenshot with Show Layout Bounds turned on so you can see that the hints go all the way to the edge of the view. Save this answer.

How do you make EditText Uneditable?

In your xml code set focusable="false" , android:clickable="false" and android:cursorVisible="false" and this will make your EditText treat like non editable.

What is EditText control?

A EditText is an overlay over TextView that configures itself to be editable. It is the predefined subclass of TextView that includes rich editing capabilities.


1 Answers

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

<EditText
    ...
    android:paddingLeft="0dp"
    android:paddingRight="0dp"
    ... />
like image 124
Tomasz Nguyen Avatar answered Sep 22 '22 04:09

Tomasz Nguyen