【问题标题】:Android app-compat Toolbar StylingAndroid 应用兼容工具栏样式
【发布时间】:2015-03-01 18:03:32
【问题描述】:

我现在有更大的问题,我如何为 kitkat / jellybean 上的工具栏图标着色。在棒棒糖上,我可以使用

        <item name="android:textColorSecondary">@color/ttdPrimaryColor</item>

这似乎是一次旅行,但在 kitkat 上没有这样的运气。

我想弄清楚如何为工具栏上的菜单图标设置主题。我需要保持标题为白色,但我希望菜单图标为不同颜色。

这是我目前的风格:

 <style name="ToolBarStyle" parent="@style/ThemeOverlay.AppCompat.ActionBar">
    <item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
    <item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>

    <item name="android:textColorPrimary">@color/white</item>
    <item name="android:textColorSecondary">?colorPrimary</item>
    <item name="actionMenuTextColor">@android:color/white</item>
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>

工具栏看起来像:

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar_actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/abc_action_bar_default_height_material"
app:popupTheme="@style/Theme.AppCompat.Light.NoActionBar"
app:theme="@style/ToolBarStyle" />

另一个问题是,在大多数活动中,我希望抽屉开关成为应用程序的原色,但在某些活动中,我希望它是白色的。处理这个问题的最佳方法是什么。

谢谢, 内森

【问题讨论】:

标签: android android-actionbar android-theme android-styles android-toolbar


【解决方案1】:

您可以为您的活动(而不是工具栏)定义一个主题。 像这样的:

<style name="MyTheme" parent="Theme.AppCompat">
   <item name="drawerArrowStyle">@style/MyDrawerArrowToggle</item>
</style>

<style name="MyDrawerArrowToggle"  
          parent="Widget.AppCompat.DrawerArrowToggle">
  <item name="color">@color/my_color</item>
</style>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-18
    • 1970-01-01
    • 1970-01-01
    • 2015-07-28
    • 2019-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多