ToolBar Style

时间:2023-03-09 08:48:36
ToolBar Style
  • colorPrimaryDark

    • 状态栏背景色。

    • 在 style 的属性中设置。

  • textColorPrimary

    • App bar 上的标题与更多菜单中的文字颜色。

    • 在 style 的属性中设置。

  • App bar 的背景色

    • Actionbar 的背景色设定在 style 中的 colorPrimary。

    • Toolbar 的背景色在layout文件中设置background属性。

  • colorAccent

    • 各控制元件(如:check box、switch 或是 radoi) 被勾选 (checked) 或是选定 (selected) 的颜色。

    • 在 style 的属性中设置。

  • colorControlNormal

    • 各控制元件的预设颜色。

    • 在 style 的属性中设置

  • windowBackground

    • App 的背景色。

    • 在 style 的属性中设置

  • navigationBarColor

    • 导航栏的背景色,但只能用在 API Level 21 (Android 5) 以上的版本

    • 在 style 的属性中设置

更改颜色需要注意 :

1.setSupportActionBar(toolbar);

更改menu的文字颜色、背景颜色、弹出颜色注意:

2.app:popupTheme="@style/ToolbarPopupTheme"

<style name="ToolbarPopupTheme" parent="@style/ThemeOverlay.AppCompat">
<item name="android:colorBackground">@color/colorPrimary</item>
</style>
<style name="AppTheme" parent="AppTheme.Base"/>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowNoTitle">true</item>
<!-- toolbar标题文字颜色 -->
<item name="android:textColorPrimary">@android:color/white</item>
<item name="alertDialogTheme">@style/AlertDialogCustom</item>
<!-- <item name="toolbarStyle">@style/Widget.Toolbar</item> -->
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorControlNormal">@android:color/white</item>
</style>
<application
android:name=".WifixApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/AppTheme">