I'm trying to change the textcolor in toolbar to white but the color wont change.
Things i've tried:
1- Changing the app:theme=app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
2- trying to do it programmatically: toolbar.setTitleTextColor(0xFFFFFFFF);
3- The last one which code appears under:
Custom style: ToolBarstyle:
Res/style
<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>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>
Res/Layout
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:theme="@style/ToolBarStyle"
app:popupTheme="@style/ThemeOverlay.AppCompat"
app:layout_collapseMode="pin" />
Java file:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
/* Toolbar */
getSupportActionBar().setTitle("Nostrils");
toolbar.setTitleTextColor(0xFFFFFFFF);
// Back icon
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
initNavigationDrawer();
}
Photo from the emulator:
https://i.imgur.com/zkp24dK.png
Change your toolbar to
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimaryDark"
app:popupTheme="@style/AppTheme.PopupOverlay"
android:id="@+id/toolbar">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:textSize="16dp"
android:textStyle="bold"
android:maxLines="1"
android:ellipsize="end"
android:textColor="@color/white"
android:layout_marginRight="?attr/actionBarSize"
android:gravity="center"
android:id="@+id/welcome_textView"/>
</android.support.v7.widget.Toolbar>
Access this textView
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
TextView textToolHeader = (TextView) toolbar.findViewById(R.id.welcome_textView);
textToolHeader.setTextColor(getResources().getColor(R.color.your_color));
For the toolbar set:
app:titleTextColor="@android:color/white"
or in your app theme set:
<item name="android:textColorPrimary">@android:color/white</item>
https://stackoverflow.com/a/25162981/4409113
Theme.AppCompat
is visually the same as Theme.Holo (dark)
So, just change parent:
<style name="ToolBarStyle" parent="Theme.AppCompat">
To:
<style name="ToolBarStyle" parent="Theme.AppCompat.Light.NoActionBar">
Because you already have a Toolbar
in your layout and this theme will make the color white.
Thanks for the answer but since its part if a collapsing toolbar i added this code (and it worked):
app:collapsedTitleTextAppearance="@style/CollapsedAppBar"
app:expandedTitleTextAppearance="@style/ExpandedAppBar"
to :
<android.support.design.widget.CollapsingToolbarLayout
with:
<style name="ExpandedAppBar" parent="@android:style/TextAppearance">
<item name="android:textSize">24sp</item>
<item name="android:textColor">@android:color/white</item>
</style>
<style name="CollapsedAppBar" parent="@android:style/TextAppearance">
<item name="android:textColor">@android:color/white</item>
</style>
User contributions licensed under CC BY-SA 3.0