【问题标题】:making action buttons of the ActionBar white将 ActionBar 的操作按钮设置为白色
【发布时间】:2015-01-21 20:53:07
【问题描述】:

我想将ActionBar android.support.v7.widget.Toolbar动作按钮的颜色设为白色。我不想使用自定义资源。 我知道当我使用 DarkTheme 时,按钮会自动变为白色,但我使用的是 transparent ActionBar,我不想通过向我的应用程序添加新资源来增加开销.

我可以通过使用

轻松地为 DrawerLayout 中的箭头按钮执行此操作

<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle"> <item name="color">@android:color/white</item> </style>

【问题讨论】:

    标签: android android-layout android-actionbar android-toolbar android-button


    【解决方案1】:

    您可以使用工具栏来定义主题和样式:

    <android.support.v7.widget.Toolbar
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            style="@style/HeaderBar"
            app:theme="@style/ActionBarThemeOverlay"
            app:popupTheme="@style/ActionBarPopupThemeOverlay"/>
    

    您可以使用这些样式完全控制您的 ui 元素:

     <style name="ActionBarThemeOverlay" parent="">
         <item name="android:textColorPrimary">#fff</item>
         <item name="colorControlNormal">#fff</item>
         <item name="colorControlHighlight">#3fff</item>
     </style>
    
    
    <style name="HeaderBar">
        <!-- Define the toolbar background -->
        <item name="android:background">xxxx</item>
    </style>
    

    【讨论】:

    • 我的 .xml 在检查时显示此消息Namespace 'app' is not bound
    • 我通过将&lt;item name="colorControlNormal"&gt;#fff&lt;/item&gt; 直接用作属性使其工作,但我不知道如何修复该命名空间检查错误。如果你能告诉我如何解决这个问题会很有帮助
    • 您必须在布局的根元素中使用 xmlns:app="schemas.android.com/apk/res-auto" 定义自定义命名空间
    • 非常感谢您的帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-04
    • 1970-01-01
    • 1970-01-01
    • 2015-03-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多