Extends the width of the search view.
This commit is contained in:
parent
65e9d8c4fd
commit
100b9f0a47
4 changed files with 15 additions and 2 deletions
|
@ -89,7 +89,8 @@ public class SearchActivity extends BaseActivity implements SearchView.OnQueryTe
|
||||||
super.onCreateOptionsMenu(menu);
|
super.onCreateOptionsMenu(menu);
|
||||||
|
|
||||||
getMenuInflater().inflate(R.menu.search_toolbar, menu);
|
getMenuInflater().inflate(R.menu.search_toolbar, menu);
|
||||||
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
|
SearchView searchView = (SearchView) menu.findItem(R.id.action_search)
|
||||||
|
.getActionView();
|
||||||
setupSearchView(searchView);
|
setupSearchView(searchView);
|
||||||
|
|
||||||
if (currentQuery != null) {
|
if (currentQuery != null) {
|
||||||
|
@ -160,6 +161,8 @@ public class SearchActivity extends BaseActivity implements SearchView.OnQueryTe
|
||||||
searchView.setOnQueryTextListener(this);
|
searchView.setOnQueryTextListener(this);
|
||||||
searchView.setFocusable(false);
|
searchView.setFocusable(false);
|
||||||
searchView.setFocusableInTouchMode(false);
|
searchView.setFocusableInTouchMode(false);
|
||||||
|
|
||||||
|
searchView.setMaxWidth(Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void search(String query) {
|
private void search(String query) {
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
android:background="?attr/toolbar_background_color"
|
android:background="?attr/toolbar_background_color"
|
||||||
app:navigationIcon="?attr/homeAsUpIndicator" />
|
app:navigationIcon="?attr/homeAsUpIndicator"
|
||||||
|
app:contentInsetStartWithNavigation="0dp" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
8
app/src/main/res/layout/search_view.xml
Normal file
8
app/src/main/res/layout/search_view.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.v7.widget.SearchView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:searchHintIcon="@null"
|
||||||
|
android:maxWidth="10000dp" />
|
|
@ -6,5 +6,6 @@
|
||||||
android:title="@string/action_search"
|
android:title="@string/action_search"
|
||||||
android:icon="@android:drawable/ic_menu_search"
|
android:icon="@android:drawable/ic_menu_search"
|
||||||
app:actionViewClass="android.support.v7.widget.SearchView"
|
app:actionViewClass="android.support.v7.widget.SearchView"
|
||||||
|
android:actionLayout="@layout/search_view"
|
||||||
app:showAsAction="always" />
|
app:showAsAction="always" />
|
||||||
</menu>
|
</menu>
|
Loading…
Reference in a new issue