Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 如何在材料设计中的工具栏上添加搜索按钮大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_450_0@
我试图在弹出的设置左侧添加搜索按钮,但我无添加工具栏.

这是我的menu.xml代码

<menu xmlns:android="http://scheR_976_11845@as.android.com/apk/res/android"
    xmlns:tools="http://scheR_976_11845@as.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@R_692_6964@="@String/action_search"/>
    <item
        android:id="@+id/action_setTings"
        android:orderInCategory="100"
        android:showAsAction="never"
        android@R_692_6964@="@String/action_setTings"/>

</menu>

这是我的toolbar.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://scheR_976_11845@as.android.com/apk/res/android"
    xmlns:local="http://scheR_976_11845@as.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" />

我正在获取工具栏但没有获得搜索按钮?

解决方法

使用app:showAsAction =“always”在你的menu.xml中使用Xmlns:app =“http://scheR_976_11845@as.android.com/apk/res-auto”>在您的菜单标签

大佬总结

以上是大佬教程为你收集整理的android – 如何在材料设计中的工具栏上添加搜索按钮全部内容,希望文章能够帮你解决android – 如何在材料设计中的工具栏上添加搜索按钮所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。