Paul Verest
Paul Verest

Reputation: 63872

Android: make text and drawable inside EditText to have padding

There is EditText pictured on the left.
How to make text inside EditText and drawableRight to have padding as on the right?

enter image description here

The EditText has rounded corners, see android:background, however there is no interval set from EditText left edge to text start and from drawableRight to the EditText right edge.

<EditText
    android:id="@+id/search_editbox"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_gravity="center_vertical"
    android:layout_toLeftOf="@id/search_execute_imageview"
    android:layout_toRightOf="@id/layout_back_logo"
    android:background="@drawable/rounded_edittext_states"
    android:drawableRight="@drawable/abc_ic_clear_holo_light"
    android:gravity="left|center_vertical"
    android:hint="@string/search_hint"
    android:maxLength="20"
    android:padding="5dip"
    android:singleLine="true"
    android:textCursorDrawable="@null"
    android:textSize="@dimen/main_text_size" />

I tried

    android:paddingLeft="30dp"
    android:paddingRight="30dp"

but it had no result.

Upvotes: 1

Views: 692

Answers (1)

amit singh
amit singh

Reputation: 1422

Try this, it will work-

android:drawablePadding="30dp" for interval between drawable and text.

Edit: actually remove padding and paddingLeft and paddingRight

Upvotes: 1

Related Questions