How to change change text and arrow color on Toolbar?

吃可爱长大的小学妹 提交于 2019-12-01 03:29:54

Here is complete style for your toolbar. Explanation is given inline.

<style name="MyToolbar" parent="@style/ThemeOverlay.AppCompat">
    <!-- Title text -->
    <item name="android:textColorPrimary">@android:color/white</item>

    <!-- Title color in AppCompat.Light  -->
    <item name="android:textColorPrimaryInverse">@android:color/white</item>

    <!-- Menu text-->
    <item name="actionMenuTextColor">@android:color/white</item>
    <!-- Overflow -->
    <item name="android:textColorSecondary">@android:color/white</item>
    <!-- This will change drawer icon -->
    <item name="drawerArrowStyle">@style/WhiteDrawerIconStyle</item>
    <!-- background of the  -->
    <!-- <item name="android:background">@color/color_primary</item> -->
</style>


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

On subtitle note: You can use mToolbar.setSubtitle(sutitle);

Put app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" to your Toolbar xml. And arrow turns white.

   <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="@dimen/toolbar_height"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

In your app bar, add this property.

app:theme = "@style/Base.V7.Theme.AppCompat"

That should take care of all the whiting. The referenced theme consists of a toolbar with white items, so the toolbar takes the part of the theme that is relevant to it.

Call mToolbar.setSubtitle as discussed above.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!