android - 如何在 editText 中删除这个空格?

标签 android android-edittext

这是我的xml文件代码

<?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>

此 xml 显示输出如下图,

enter image description here

如您所见,我在 EditText 框中显示了一张图片。我想删除那些填充类型空间(标记为红色)。

我应该怎么做才能删除它?

最佳答案

使用

android:drawablePadding="-2dip"

或您需要的任何值。由于您正在使用 drawableLeft 项,因此您还需要 drawablePadding 项来调整其填充

关于android - 如何在 editText 中删除这个空格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23625009/

相关文章:

android - 从子 RecyclerView 更新父 RecyclerView 中的值

android - 如何在 for 循环中用 ImageView 替换字符串,需要逻辑

android - EditText,如何控制TextWatcher中的光标?

Android - 以编程方式更改 EditTextPreference 对话框的肯定按钮文本

android - 在屏幕底部显示 AdMob 横幅

android - 如何在android中获取连接的蓝牙设备数据?

android - RxJava : Know when observable is finished and return Boolean Observable to the caller

java - 从 EditText 读取行并将字符串添加到 ArrayList

android - EditText 中左侧可绘制对象和文本之间的间隙

android - 如何验证android中的编辑文本,使其最多包含6位和小数点后2位?