Tôi đang cố gắng thêm nút tìm kiếm ở bên trái của cài đặt bật lên nhưng tôi không thể thêm vào thanh công cụ.Cách thêm nút tìm kiếm trên thanh công cụ trong thiết kế material design
Đây là mã của tôi về menu.xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.materialtheme.MainActivity" >
<item
android:id="@+id/action_search"
android:icon="@drawable/ic_launcher"
android:menuCategory="secondary"
android:showAsAction="ifRoom"
android:title="@string/action_search"/>
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
</menu>
và đây là toolbar.xml tôi:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:elevation="4dp"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
Tôi nhận được thanh công cụ nhưng không nhận được nút tìm kiếm?
Vui lòng sử dụng wrapper đơn giản này;) https://gist.github.com/ademar111190/7d31dab71502e6a85b8a –