0
在我的片段中,我使用searchView(不在工具栏中)。 我的布局片段:SearchView在片段中(非工具栏中)无法删除下划线
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:layout_height="match_parent">
<android.support.v7.widget.SearchView
android:id="@+id/searchView"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_marginEnd="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
app:queryHint="Some hint"
android:layout_marginStart="20dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:searchHintIcon="@null" />
</android.support.constraint.ConstraintLayout>
在我的片段代码:
searchView = view.findViewById(R.id.searchView);
SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
searchView.setSuggestionsAdapter(new SearchCatalogSuggestionsAdapter(getActivity()));
searchView.setBackgroundColor(Color.parseColor("#FFFFFF"));
正如你可以看到我尝试
searchView.setBackgroundColor(Color.parseColor("#FFFFFF"));
但强调没有帮助。 这里截图:
尝试将'searchview'设置为null(适用于'AutoCompleteTextView')。 –
@LalitSinghFauzdar SearchView实际上是一个LinearLayout,并且它的背景设置在EditText里面,所以这是行不通的。 –
android:background =“@ null” - 没有帮助 – Alexei