我了解我们可以在活动工具栏中添加搜索小部件。根据我的要求,我们不能在搜索小部件中使用工具栏,是否可以将搜索小部件作为单独的实体活动在工具条下方或我们想要的任何位置(如“文本视图”或“按钮”)?
我已经创建了搜索视图xml,并通过包括我想要的任何位置来使用它。
<LinearLayout 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"
android:background="@color/colorPrimary"
android:padding="16dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@android:color/white"
app:cardElevation="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.SearchView
android:id="@+id/searchView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:queryHint="Search..">
</android.support.v7.widget.SearchView>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
包括在布局中
<include layout="@layout/search_view" />
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句