答案 0 :(得分:0)
我做到了。我从菜单中删除了SearchView并将其放入主布局中。我的布局xml如下所示:
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
<include
android:id="@+id/tool_bar"
layout="@layout/toolbar_home" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorToolBar"
android:paddingBottom="16dp"
android:elevation="4dp">
<android.support.v7.widget.SearchView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:id="@+id/main_home_search"
android:background="@color/searchBackgroundColor"
android:focusable="false"
app:queryHint="@string/main_home_search"
app:queryBackground="@android:color/transparent"
app:iconifiedByDefault="false"
/>
</LinearLayout>
<include layout="@layout/activity_main_home_content" />
</LinearLayout>