Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中删除SearchView中SearchIcon和文本之间的空格?_Android_Searchview - Fatal编程技术网

如何在android中删除SearchView中SearchIcon和文本之间的空格?

如何在android中删除SearchView中SearchIcon和文本之间的空格?,android,searchview,Android,Searchview,我正在使用SearchView,它的显示方式如下: 我想喜欢这个 我没有使用动作栏。那么,如何在SearchView中删除SearchIcon和文本之间的空格呢?这怎么可能?请引导我 And My XML file is, <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:too

我正在使用SearchView,它的显示方式如下:

我想喜欢这个

我没有使用动作栏。那么,如何在SearchView中删除SearchIcon和文本之间的空格呢?这怎么可能?请引导我

And My XML file is, 

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <SearchView
        android:id="@+id/svSearch"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="@dimen/five_dp" >
    </SearchView>

    <ListView
        android:id="@+id/lstSearch"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/svSearch" >
    </ListView>

</RelativeLayout>

我也遇到了同样的问题,我通过编程方式修改了搜索视图中呈现文本视图的填充来解决了这个问题

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Reduce space between search icon and text
    SearchView searchView = (SearchView) findViewById(R.id.action_search);
    TextView textView = (TextView) searchView.findViewById(R.id.search_src_text);
    textView.setPadding(2, 0, 0, 0);
    return true;
}

对编辑文本应用填充权限。我使用的是SearchView而不是EditText。那么您是否应用了填充权限?是否使用actionbar SearchView?@PiyushGupta是的,我应用了填充权限,但无法进行任何更改。