Android中ActIonBar外部的搜索栏

Android中ActIonBar外部的搜索栏,android,android-fragments,android-actionbar,android-search,Android,Android Fragments,Android Actionbar,Android Search,我想在我的应用程序中添加一个搜索栏,类似于Zomato所做的。我已经搜索了很多,我已经学会了搜索界面是一条路要走,但在我所看到的任何地方,它都被添加到了动作栏中,而我希望它出现在一些片段中(固定活动)。是否有其他方式可以添加搜索(zomato是如何添加的) 是否需要打开另一个活动进行搜索,或者我可以打开另一个片段进行搜索?如@pskink所说,您可以在布局中的任何位置添加SearchView,如下所示: <LinearLayout xmlns:android="http://sch

我想在我的应用程序中添加一个搜索栏,类似于Zomato所做的。我已经搜索了很多,我已经学会了搜索界面是一条路要走,但在我所看到的任何地方,它都被添加到了动作栏中,而我希望它出现在一些片段中(固定活动)。是否有其他方式可以添加搜索(zomato是如何添加的)


是否需要打开另一个活动进行搜索,或者我可以打开另一个片段进行搜索?

如@pskink所说,您可以在布局中的任何位置添加SearchView,如下所示:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <SearchView
            android:id="@+id/searchView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        </SearchView>
    </LinearLayout>

SearchView是一个nornal视图,因此您可以在任何地方添加它