Android ToolBar can change back button color but not title color
I want to change my Toolbar
title color to blue. It stays white. I was able to set the back button but not the title color - am I missing something?
I've tried to change it at 3 different places:
Activity
Toolbar toolbar = (Toolbar) findViewById(R.id.detail_toolbar);
toolbar.setTitleTextColor(0xff00ff99);
setSupportActionBar(toolbar);
activity.xml
<android.support.v7.widget.Toolbar
android:id="@+id/detail_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:theme="@style/ToolBarStyle"
android:background="@color/colorPrimaryDark"
android:titleTextColor="@android:color/holo_red_dark"
app:subtitleTextColor="@color/colorPrimaryDark"
app:layout_collapseMode="pin"
app:popupTheme="@style/ToolBarStyle" />
v21 styles.xml
<!-- ToolBar -->
<style name="ToolBarStyle" parent="Theme.AppCompat">
<item name="titleTextColor">@color/colorPrimaryDark</item>
<item name="android:titleTextColor">@color/colorPrimaryDark</item>
<item name="android:textColorPrimary">@color/colorPrimaryDark</item>
<item name="android:textColorSecondary">@color/colorPrimaryDark</item>
<item name="actionMenuTextColor">@color/colorPrimaryDark</item>
<item name="android:textColor">@color/colorPrimaryDark</item>
</style>
styles.xml
<style name="ToolBarStyle" parent="Theme.AppCompat">
<item name="titleTextColor">@color/colorPrimaryDark</item>
<item name="android:titleTextColor">@color/colorPrimaryDark</item>
<item name="android:textColorPrimary">@color/colorPrimaryDark</item>
<item name="android:textColorSecondary">@color/colorPrimaryDark</item>
<item name="actionMenuTextColor">@color/colorPrimaryDark</item>
<item name="android:textColor">@color/colorPrimaryDark</item>
</style>
What am I missing?
It stays white no matter what. I've even went through the 150 references to #ffffff in the whole project and nowhere is the toolbar referenced there.
targetSdk 26, running on Android 7.1.1
android toolbar android-xml appcompat
add a comment |
I want to change my Toolbar
title color to blue. It stays white. I was able to set the back button but not the title color - am I missing something?
I've tried to change it at 3 different places:
Activity
Toolbar toolbar = (Toolbar) findViewById(R.id.detail_toolbar);
toolbar.setTitleTextColor(0xff00ff99);
setSupportActionBar(toolbar);
activity.xml
<android.support.v7.widget.Toolbar
android:id="@+id/detail_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:theme="@style/ToolBarStyle"
android:background="@color/colorPrimaryDark"
android:titleTextColor="@android:color/holo_red_dark"
app:subtitleTextColor="@color/colorPrimaryDark"
app:layout_collapseMode="pin"
app:popupTheme="@style/ToolBarStyle" />
v21 styles.xml
<!-- ToolBar -->
<style name="ToolBarStyle" parent="Theme.AppCompat">
<item name="titleTextColor">@color/colorPrimaryDark</item>
<item name="android:titleTextColor">@color/colorPrimaryDark</item>
<item name="android:textColorPrimary">@color/colorPrimaryDark</item>
<item name="android:textColorSecondary">@color/colorPrimaryDark</item>
<item name="actionMenuTextColor">@color/colorPrimaryDark</item>
<item name="android:textColor">@color/colorPrimaryDark</item>
</style>
styles.xml
<style name="ToolBarStyle" parent="Theme.AppCompat">
<item name="titleTextColor">@color/colorPrimaryDark</item>
<item name="android:titleTextColor">@color/colorPrimaryDark</item>
<item name="android:textColorPrimary">@color/colorPrimaryDark</item>
<item name="android:textColorSecondary">@color/colorPrimaryDark</item>
<item name="actionMenuTextColor">@color/colorPrimaryDark</item>
<item name="android:textColor">@color/colorPrimaryDark</item>
</style>
What am I missing?
It stays white no matter what. I've even went through the 150 references to #ffffff in the whole project and nowhere is the toolbar referenced there.
targetSdk 26, running on Android 7.1.1
android toolbar android-xml appcompat
add a comment |
I want to change my Toolbar
title color to blue. It stays white. I was able to set the back button but not the title color - am I missing something?
I've tried to change it at 3 different places:
Activity
Toolbar toolbar = (Toolbar) findViewById(R.id.detail_toolbar);
toolbar.setTitleTextColor(0xff00ff99);
setSupportActionBar(toolbar);
activity.xml
<android.support.v7.widget.Toolbar
android:id="@+id/detail_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:theme="@style/ToolBarStyle"
android:background="@color/colorPrimaryDark"
android:titleTextColor="@android:color/holo_red_dark"
app:subtitleTextColor="@color/colorPrimaryDark"
app:layout_collapseMode="pin"
app:popupTheme="@style/ToolBarStyle" />
v21 styles.xml
<!-- ToolBar -->
<style name="ToolBarStyle" parent="Theme.AppCompat">
<item name="titleTextColor">@color/colorPrimaryDark</item>
<item name="android:titleTextColor">@color/colorPrimaryDark</item>
<item name="android:textColorPrimary">@color/colorPrimaryDark</item>
<item name="android:textColorSecondary">@color/colorPrimaryDark</item>
<item name="actionMenuTextColor">@color/colorPrimaryDark</item>
<item name="android:textColor">@color/colorPrimaryDark</item>
</style>
styles.xml
<style name="ToolBarStyle" parent="Theme.AppCompat">
<item name="titleTextColor">@color/colorPrimaryDark</item>
<item name="android:titleTextColor">@color/colorPrimaryDark</item>
<item name="android:textColorPrimary">@color/colorPrimaryDark</item>
<item name="android:textColorSecondary">@color/colorPrimaryDark</item>
<item name="actionMenuTextColor">@color/colorPrimaryDark</item>
<item name="android:textColor">@color/colorPrimaryDark</item>
</style>
What am I missing?
It stays white no matter what. I've even went through the 150 references to #ffffff in the whole project and nowhere is the toolbar referenced there.
targetSdk 26, running on Android 7.1.1
android toolbar android-xml appcompat
I want to change my Toolbar
title color to blue. It stays white. I was able to set the back button but not the title color - am I missing something?
I've tried to change it at 3 different places:
Activity
Toolbar toolbar = (Toolbar) findViewById(R.id.detail_toolbar);
toolbar.setTitleTextColor(0xff00ff99);
setSupportActionBar(toolbar);
activity.xml
<android.support.v7.widget.Toolbar
android:id="@+id/detail_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:theme="@style/ToolBarStyle"
android:background="@color/colorPrimaryDark"
android:titleTextColor="@android:color/holo_red_dark"
app:subtitleTextColor="@color/colorPrimaryDark"
app:layout_collapseMode="pin"
app:popupTheme="@style/ToolBarStyle" />
v21 styles.xml
<!-- ToolBar -->
<style name="ToolBarStyle" parent="Theme.AppCompat">
<item name="titleTextColor">@color/colorPrimaryDark</item>
<item name="android:titleTextColor">@color/colorPrimaryDark</item>
<item name="android:textColorPrimary">@color/colorPrimaryDark</item>
<item name="android:textColorSecondary">@color/colorPrimaryDark</item>
<item name="actionMenuTextColor">@color/colorPrimaryDark</item>
<item name="android:textColor">@color/colorPrimaryDark</item>
</style>
styles.xml
<style name="ToolBarStyle" parent="Theme.AppCompat">
<item name="titleTextColor">@color/colorPrimaryDark</item>
<item name="android:titleTextColor">@color/colorPrimaryDark</item>
<item name="android:textColorPrimary">@color/colorPrimaryDark</item>
<item name="android:textColorSecondary">@color/colorPrimaryDark</item>
<item name="actionMenuTextColor">@color/colorPrimaryDark</item>
<item name="android:textColor">@color/colorPrimaryDark</item>
</style>
What am I missing?
It stays white no matter what. I've even went through the 150 references to #ffffff in the whole project and nowhere is the toolbar referenced there.
targetSdk 26, running on Android 7.1.1
android toolbar android-xml appcompat
android toolbar android-xml appcompat
edited Nov 23 at 7:48
tm13
5281220
5281220
asked Nov 23 at 0:35
user2875404
1,34221428
1,34221428
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
Create custom Toolbar
like this:
toolbar_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="false"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@android:color/backgroundColor"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/Base.Theme.AppCompat.Light.DarkActionBar">
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/blue"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
Include it in you layout:
<include layout="@layout/toolbar_layout"/>
Use it in your activity's onCreate method:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_card);
Toolbar toolbar = findViewById(R.id.toolbar);
TextView toolbarTitle = findViewById(R.id.toolbar_title);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null)
getSupportActionBar().setDisplayShowTitleEnabled(false);
toolbarTitle.setText("Your title");
...
}
Hope it will help.
add a comment |
Try to change this:
android:titleTextColor="@android:color/holo_red_dark"
to:
app:titleTextColor="@android:color/holo_red_dark"
in your activity.xml android.support.v7.widget.Toolbar
section.
Tried that, not working unfortunately :(
– user2875404
Nov 23 at 0:50
It should, Also no need this in styles.xml. Try to remove this line: <item name="android:titleTextColor">@color/colorPrimaryDark</item> Some style definition interfere to other. Should remove unnecessary items in styles
– Sinan Ceylan
Nov 23 at 0:52
Hey mate, I've found the issue now. Will write answer in a minute
– user2875404
Nov 23 at 0:58
I've added my answer. Thanks a lot for your support tho, keep it up my friend!
– user2875404
Nov 23 at 1:09
add a comment |
Ok so I have found the answer by literally stack tracing my code.
I have a PagerAdapter returning different fragments. I thought that each Activity
was responsible to the Tabbar
(it's a Master/Detail pattern for different tabs each) as I've had to set stuff like setSupportActionBar()
which I've done in the subsequent Activities
.
Stacktracing my code I've realized that there is a CollapsingToolbarLayout
being find by view ID. This is where I set the bar's title. From there, I didn't find any title property but I've let auto complete lead me to setCollapsedTitleTextColor
and setExpandedTitleColor
.
So although the getColor()
part is deprecated it's
bar.setCollapsedTitleTextColor(getResources().getColor(R.color.colorPrimaryDark));
bar.setExpandedTitleColor(getResources().getColor(R.color.colorPrimaryDark));
Still no idea why all the other places I've set it at didn't do the trick but very happy it's working now.
add a comment |
In Layout file use the Toolbar as Child layout of AppBarLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
</LinearLayout>
Style.xml
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
Inside MainActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439427%2fandroid-toolbar-can-change-back-button-color-but-not-title-color%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Create custom Toolbar
like this:
toolbar_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="false"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@android:color/backgroundColor"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/Base.Theme.AppCompat.Light.DarkActionBar">
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/blue"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
Include it in you layout:
<include layout="@layout/toolbar_layout"/>
Use it in your activity's onCreate method:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_card);
Toolbar toolbar = findViewById(R.id.toolbar);
TextView toolbarTitle = findViewById(R.id.toolbar_title);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null)
getSupportActionBar().setDisplayShowTitleEnabled(false);
toolbarTitle.setText("Your title");
...
}
Hope it will help.
add a comment |
Create custom Toolbar
like this:
toolbar_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="false"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@android:color/backgroundColor"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/Base.Theme.AppCompat.Light.DarkActionBar">
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/blue"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
Include it in you layout:
<include layout="@layout/toolbar_layout"/>
Use it in your activity's onCreate method:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_card);
Toolbar toolbar = findViewById(R.id.toolbar);
TextView toolbarTitle = findViewById(R.id.toolbar_title);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null)
getSupportActionBar().setDisplayShowTitleEnabled(false);
toolbarTitle.setText("Your title");
...
}
Hope it will help.
add a comment |
Create custom Toolbar
like this:
toolbar_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="false"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@android:color/backgroundColor"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/Base.Theme.AppCompat.Light.DarkActionBar">
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/blue"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
Include it in you layout:
<include layout="@layout/toolbar_layout"/>
Use it in your activity's onCreate method:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_card);
Toolbar toolbar = findViewById(R.id.toolbar);
TextView toolbarTitle = findViewById(R.id.toolbar_title);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null)
getSupportActionBar().setDisplayShowTitleEnabled(false);
toolbarTitle.setText("Your title");
...
}
Hope it will help.
Create custom Toolbar
like this:
toolbar_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="false"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@android:color/backgroundColor"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/Base.Theme.AppCompat.Light.DarkActionBar">
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/blue"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
Include it in you layout:
<include layout="@layout/toolbar_layout"/>
Use it in your activity's onCreate method:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_card);
Toolbar toolbar = findViewById(R.id.toolbar);
TextView toolbarTitle = findViewById(R.id.toolbar_title);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null)
getSupportActionBar().setDisplayShowTitleEnabled(false);
toolbarTitle.setText("Your title");
...
}
Hope it will help.
answered Nov 23 at 5:19
tm13
5281220
5281220
add a comment |
add a comment |
Try to change this:
android:titleTextColor="@android:color/holo_red_dark"
to:
app:titleTextColor="@android:color/holo_red_dark"
in your activity.xml android.support.v7.widget.Toolbar
section.
Tried that, not working unfortunately :(
– user2875404
Nov 23 at 0:50
It should, Also no need this in styles.xml. Try to remove this line: <item name="android:titleTextColor">@color/colorPrimaryDark</item> Some style definition interfere to other. Should remove unnecessary items in styles
– Sinan Ceylan
Nov 23 at 0:52
Hey mate, I've found the issue now. Will write answer in a minute
– user2875404
Nov 23 at 0:58
I've added my answer. Thanks a lot for your support tho, keep it up my friend!
– user2875404
Nov 23 at 1:09
add a comment |
Try to change this:
android:titleTextColor="@android:color/holo_red_dark"
to:
app:titleTextColor="@android:color/holo_red_dark"
in your activity.xml android.support.v7.widget.Toolbar
section.
Tried that, not working unfortunately :(
– user2875404
Nov 23 at 0:50
It should, Also no need this in styles.xml. Try to remove this line: <item name="android:titleTextColor">@color/colorPrimaryDark</item> Some style definition interfere to other. Should remove unnecessary items in styles
– Sinan Ceylan
Nov 23 at 0:52
Hey mate, I've found the issue now. Will write answer in a minute
– user2875404
Nov 23 at 0:58
I've added my answer. Thanks a lot for your support tho, keep it up my friend!
– user2875404
Nov 23 at 1:09
add a comment |
Try to change this:
android:titleTextColor="@android:color/holo_red_dark"
to:
app:titleTextColor="@android:color/holo_red_dark"
in your activity.xml android.support.v7.widget.Toolbar
section.
Try to change this:
android:titleTextColor="@android:color/holo_red_dark"
to:
app:titleTextColor="@android:color/holo_red_dark"
in your activity.xml android.support.v7.widget.Toolbar
section.
edited Nov 23 at 5:23
Rahul Sharma
2,1691418
2,1691418
answered Nov 23 at 0:48
Sinan Ceylan
37917
37917
Tried that, not working unfortunately :(
– user2875404
Nov 23 at 0:50
It should, Also no need this in styles.xml. Try to remove this line: <item name="android:titleTextColor">@color/colorPrimaryDark</item> Some style definition interfere to other. Should remove unnecessary items in styles
– Sinan Ceylan
Nov 23 at 0:52
Hey mate, I've found the issue now. Will write answer in a minute
– user2875404
Nov 23 at 0:58
I've added my answer. Thanks a lot for your support tho, keep it up my friend!
– user2875404
Nov 23 at 1:09
add a comment |
Tried that, not working unfortunately :(
– user2875404
Nov 23 at 0:50
It should, Also no need this in styles.xml. Try to remove this line: <item name="android:titleTextColor">@color/colorPrimaryDark</item> Some style definition interfere to other. Should remove unnecessary items in styles
– Sinan Ceylan
Nov 23 at 0:52
Hey mate, I've found the issue now. Will write answer in a minute
– user2875404
Nov 23 at 0:58
I've added my answer. Thanks a lot for your support tho, keep it up my friend!
– user2875404
Nov 23 at 1:09
Tried that, not working unfortunately :(
– user2875404
Nov 23 at 0:50
Tried that, not working unfortunately :(
– user2875404
Nov 23 at 0:50
It should, Also no need this in styles.xml. Try to remove this line: <item name="android:titleTextColor">@color/colorPrimaryDark</item> Some style definition interfere to other. Should remove unnecessary items in styles
– Sinan Ceylan
Nov 23 at 0:52
It should, Also no need this in styles.xml. Try to remove this line: <item name="android:titleTextColor">@color/colorPrimaryDark</item> Some style definition interfere to other. Should remove unnecessary items in styles
– Sinan Ceylan
Nov 23 at 0:52
Hey mate, I've found the issue now. Will write answer in a minute
– user2875404
Nov 23 at 0:58
Hey mate, I've found the issue now. Will write answer in a minute
– user2875404
Nov 23 at 0:58
I've added my answer. Thanks a lot for your support tho, keep it up my friend!
– user2875404
Nov 23 at 1:09
I've added my answer. Thanks a lot for your support tho, keep it up my friend!
– user2875404
Nov 23 at 1:09
add a comment |
Ok so I have found the answer by literally stack tracing my code.
I have a PagerAdapter returning different fragments. I thought that each Activity
was responsible to the Tabbar
(it's a Master/Detail pattern for different tabs each) as I've had to set stuff like setSupportActionBar()
which I've done in the subsequent Activities
.
Stacktracing my code I've realized that there is a CollapsingToolbarLayout
being find by view ID. This is where I set the bar's title. From there, I didn't find any title property but I've let auto complete lead me to setCollapsedTitleTextColor
and setExpandedTitleColor
.
So although the getColor()
part is deprecated it's
bar.setCollapsedTitleTextColor(getResources().getColor(R.color.colorPrimaryDark));
bar.setExpandedTitleColor(getResources().getColor(R.color.colorPrimaryDark));
Still no idea why all the other places I've set it at didn't do the trick but very happy it's working now.
add a comment |
Ok so I have found the answer by literally stack tracing my code.
I have a PagerAdapter returning different fragments. I thought that each Activity
was responsible to the Tabbar
(it's a Master/Detail pattern for different tabs each) as I've had to set stuff like setSupportActionBar()
which I've done in the subsequent Activities
.
Stacktracing my code I've realized that there is a CollapsingToolbarLayout
being find by view ID. This is where I set the bar's title. From there, I didn't find any title property but I've let auto complete lead me to setCollapsedTitleTextColor
and setExpandedTitleColor
.
So although the getColor()
part is deprecated it's
bar.setCollapsedTitleTextColor(getResources().getColor(R.color.colorPrimaryDark));
bar.setExpandedTitleColor(getResources().getColor(R.color.colorPrimaryDark));
Still no idea why all the other places I've set it at didn't do the trick but very happy it's working now.
add a comment |
Ok so I have found the answer by literally stack tracing my code.
I have a PagerAdapter returning different fragments. I thought that each Activity
was responsible to the Tabbar
(it's a Master/Detail pattern for different tabs each) as I've had to set stuff like setSupportActionBar()
which I've done in the subsequent Activities
.
Stacktracing my code I've realized that there is a CollapsingToolbarLayout
being find by view ID. This is where I set the bar's title. From there, I didn't find any title property but I've let auto complete lead me to setCollapsedTitleTextColor
and setExpandedTitleColor
.
So although the getColor()
part is deprecated it's
bar.setCollapsedTitleTextColor(getResources().getColor(R.color.colorPrimaryDark));
bar.setExpandedTitleColor(getResources().getColor(R.color.colorPrimaryDark));
Still no idea why all the other places I've set it at didn't do the trick but very happy it's working now.
Ok so I have found the answer by literally stack tracing my code.
I have a PagerAdapter returning different fragments. I thought that each Activity
was responsible to the Tabbar
(it's a Master/Detail pattern for different tabs each) as I've had to set stuff like setSupportActionBar()
which I've done in the subsequent Activities
.
Stacktracing my code I've realized that there is a CollapsingToolbarLayout
being find by view ID. This is where I set the bar's title. From there, I didn't find any title property but I've let auto complete lead me to setCollapsedTitleTextColor
and setExpandedTitleColor
.
So although the getColor()
part is deprecated it's
bar.setCollapsedTitleTextColor(getResources().getColor(R.color.colorPrimaryDark));
bar.setExpandedTitleColor(getResources().getColor(R.color.colorPrimaryDark));
Still no idea why all the other places I've set it at didn't do the trick but very happy it's working now.
answered Nov 23 at 1:08
user2875404
1,34221428
1,34221428
add a comment |
add a comment |
In Layout file use the Toolbar as Child layout of AppBarLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
</LinearLayout>
Style.xml
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
Inside MainActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
add a comment |
In Layout file use the Toolbar as Child layout of AppBarLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
</LinearLayout>
Style.xml
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
Inside MainActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
add a comment |
In Layout file use the Toolbar as Child layout of AppBarLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
</LinearLayout>
Style.xml
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
Inside MainActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
In Layout file use the Toolbar as Child layout of AppBarLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
</LinearLayout>
Style.xml
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
Inside MainActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
answered Nov 23 at 6:04
jessica
1,0911616
1,0911616
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439427%2fandroid-toolbar-can-change-back-button-color-but-not-title-color%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown