工具栏文本颜色不会改变

问题描述:

我使用工具栏和滚动它显示的文字图像, 当我尝试在Java也toolbar.setTitleTextColor(Color.RED);但它不工作的文本颜色始终是白色工具栏文本颜色不会改变

<android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:layout_collapseMode="pin" 
      app:titleTextColor="@color/buttontext" 
      app:popupTheme="@style/appBarTheme" /> 
+0

此链接可以帮助你。 https://*.com/questions/32237284/how-to-change-toolbar-color – user3678528

+0

'textColorSecondary'将帮助你。另外也请看看[这里](https://*.com/questions/39070040/textcolor-vs-textcolorprimary-vs-textcolorsecondary) –

一下添加到风格.XML

<style name="ToolBarStyle" parent="Theme.AppCompat"> 
    <item name="android:textColorPrimary">@android:color/white</item> 
    <item name="android:textColorSecondary">@android:color/white</item> 
    <item name="actionMenuTextColor">@android:color/white</item> 
</style> 

,让你Widget.Toolbal这样的:

<android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     app:theme="@style/ToolBarStyle" 
     android:layout_height="?attr/actionBarSize" 
    /> 

您可以将<item name="actionMenuTextColor">@android:color/white</item>中的颜色更改为任何您想要的颜色。