2016-09-24 5 views
0

This is the EDIT image: it shows the space i want to remove; Я делаю поиск для своего приложения. Я просто не могу удалить значок «SearchView».Как удалить SearchView удалить Icon

Вот XML:

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:background="#e9eaea" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
android:padding="0dp" 
tools:context="com.echo.isaac.echo_simplyawesome.Search"> 

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:padding="0dp" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     app:popupTheme="@style/AppTheme.PopupOverlay" 
     android:background="@color/colorPrimary" 
     android:contentInsetStart="0dp" 
     android:contentInsetLeft="0dp" 
     app:contentInsetStart="0dp" 
     app:contentInsetLeft="0dp" 
     tools:targetApi="lollipop"> 

      <SearchView 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:id="@+id/searchView" 
       android:queryHint="@string/search" 
       android:iconifiedByDefault="false" 
       android:paddingLeft="-16dp" 
       android:paddingStart="-16dp" 
       android:theme="@style/SearchViewStyle" 
       android:background="@drawable/input_background_teal" 
       android:queryBackground="@drawable/input_background_teal" 
       tools:targetApi="lollipop_mr1" /> 

    </android.support.v7.widget.Toolbar> 


    </android.support.design.widget.AppBarLayout> 

    </android.support.design.widget.CoordinatorLayout> 

Я просто хочу, чтобы удалить значок рядом с текстовым полем SearchView. Поэтому у меня нет большого пустого пространства рядом с ним. Заранее спасибо!

ответ

0

Вы можете отменить поиск просмотра изображения по умолчанию или установить видимые пошли

int searchImgId = context.getResources().getIdentifier("android:id/search_mag_icon", null, null); 
ImageView searchImage = (ImageView) searchView.findViewById(searchImgId); 


searchImage.setVisibility(View.GONE); 
+0

Спасибо плохо попробовать это прямо сейчас и после ответа –

+0

я был в состоянии установить видимость ушла, но что еще сделал интервалы между тем же –

+1

searchImage является null для меня – jiawen

Смежные вопросы