[英]How to remove SearchView remove Icon
这是EDIT图片:它显示了我要删除的空间; 我正在搜索我的应用程序。 我只是似乎无法删除“ SearchView”图标。
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文本框旁边的图标。 所以我旁边没有空白空间。 提前致谢!
您可以覆盖搜索视图默认图像或将可见设置为已消失
int searchImgId = context.getResources().getIdentifier("android:id/search_mag_icon", null, null);
ImageView searchImage = (ImageView) searchView.findViewById(searchImgId);
searchImage.setVisibility(View.GONE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.