user2060383
user2060383

Reputation: 989

How to remove this space in editText?

Here is my code for xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white_smoke"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <include layout="@layout/header" />

        <FrameLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true" >

            <TextView
                android:id="@+id/tvAddContact"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="10dp"
                android:background="@drawable/circle_trans"
                android:gravity="center"
                android:text="@string/plus_text"
                android:textColor="@color/white_smoke"
                android:textSize="40sp" />
        </FrameLayout>
    </RelativeLayout>

    <include
        layout="@layout/header_date"
        android:paddingTop="10dp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="vertical"
        android:paddingBottom="10dp"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:paddingTop="5dp" >

        <RadioGroup
            android:id="@+id/radioGroup1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:orientation="horizontal" >

            <RadioButton
                android:id="@+id/rbDownline"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:button="@drawable/btn_radio_selector"
                android:checked="true"
                android:text="@string/rb_downline"
                android:textColor="@color/my_holo_text" />

            <RadioButton
                android:id="@+id/rbCustomer"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:button="@drawable/btn_radio_selector"
                android:checked="false"
                android:text="@string/rb_customer"
                android:textColor="@color/my_holo_text" />

        </RadioGroup>

        <EditText
            android:id="@+id/edSearchBox"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="30dp"
            android:background="@drawable/gradient_ed_bg"
            android:drawableLeft="@drawable/search"
            android:hint="@string/search_contacts"
            android:imeOptions="actionDone"
            android:padding="8dp"
            android:singleLine="true"
            android:textColorHint="@color/my_holo_trans" />

        <ListView
            android:id="@+id/listContacts"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/gradient_bg_list_view_round"
            android:cacheColorHint="#00000000"
            android:divider="#149DCF"
            android:dividerHeight="1dp"
            android:listSelector="@drawable/list_selector_match_holo"
            android:paddingBottom="5dp"
            android:paddingTop="5dp" >

            <requestFocus />
        </ListView>
    </LinearLayout>

    <include layout="@layout/actionbar_title" />

</LinearLayout>

This xml shows output as following image,

enter image description here

As you can see that I am displaying an image in EditText box. I want to remove those padding type space ( marked as red ).

What should I do to remove it ?

Upvotes: 5

Views: 3819

Answers (4)

Amin Azizzadeh
Amin Azizzadeh

Reputation: 510

use

android:drawablePadding="10dp"

Upvotes: 1

Blackbelt
Blackbelt

Reputation: 157487

use

android:drawablePadding="-2dip"

or whatever value do you need. Since you are using the drawableLeft item, you need the drawablePadding item as well, to adjust its padding

Upvotes: 1

Bhanu Sharma
Bhanu Sharma

Reputation: 5145

remove padding

 android:padding="8dp"

Upvotes: 0

duggu
duggu

Reputation: 38439

You have to remove padding from your edit text.Use below code:-

<EditText
    android:id="@+id/edSearchBox"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="30dp"
    android:background="@drawable/gradient_ed_bg"
    android:drawableLeft="@drawable/search"
    android:hint="@string/search_contacts"
    android:imeOptions="actionDone"
    android:singleLine="true"
    android:textColorHint="@color/my_holo_trans" />

Upvotes: 0

Related Questions