2014-11-08 54 views
0

我使用的搜索查看和它顯示像,enter image description here如何在android中的SearchView中刪除SearchIcon和文本之間的空間?

,我想這樣的,enter image description here

我不使用操作欄。那麼如何在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> 
+0

應用填充權的EditText。 – Piyush 2014-11-08 07:18:39

+0

<?xml version =「1.0」encoding =「utf-8」?> <搜索查看 機器人:ID = 」@ + ID/svSearch「 機器人:layout_width =」 FILL_PARENT 「 機器人:layout_height =」 WRAP_CONTENT」 機器人:layout_centerHorizo​​ntal = 「真」 機器人:layout_marginTop = 「@捫/ five_dp」> 我使用搜索查看不EditText上。 – Android 2014-11-08 07:20:28

+0

那麼你是否應用了填充權? – Piyush 2014-11-08 07:23:15

回答

0

我有同樣的問題,我解決它修改爲填充呈現TextView的搜索視圖內編程

@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; 
} 
相關問題