I need to set Title and SubTitle in my app. But In new design library using CollapsingToolbarLayout can able to set Title and scrolling with image is working fine. How to set the SubTitle in CollapsingToolbarLayout?
Asked
Active
Viewed 2,321 times
3
-
Having the same problem, looking desperately for an answer :(( – qwertz Jun 16 '15 at 13:15
-
Did you get a reference to the `Toolbar` in code, and set the `subtitle`? I tried it in my code, but it does not work; however, I am having other issues with my `CollapsingToolbarLayout` right now, and that might be why – Christopher Rucinski Jun 17 '15 at 21:52
-
When we try to set subTitle in Toolbar CollapsingToolbarLayout is not working. So we need to set the title and subTitle in CollapsingToolbarLayout – Kamalanathan Jun 18 '15 at 04:24
-
have you found a solution for it? – observer Jul 03 '15 at 14:51
-
Still not got any solution on this – Kamalanathan Jul 06 '15 at 05:29
-
No solution by far. And I think [this question](http://stackoverflow.com/questions/31069107/how-to-show-toolbars-logo-icon-title-subtitle-when-wrapped-in-a-collapsingto) is more wide. – SilentKnight Jul 06 '15 at 09:05
-
i think you have to try [this](http://stackoverflow.com/questions/26880544/setting-a-subtitle-on-my-toolbar-from-a-fragment) solution for `setTitle("")` and `setSubtitle("")` of toolbar – pRaNaY Oct 11 '15 at 06:06
-
@pRaNaY I am not trying to set the subTitle in toolbar. I need to set subTitle in CollapsingToolbarLayout so that on scroll that text will scroll and collapse. – Kamalanathan Oct 12 '15 at 04:55
-
Try this answer from another thread with the same topic: http://stackoverflow.com/a/32220854/1665562 – VladimirVip Nov 27 '15 at 20:36
-
Any update for this case? – gorbos Mar 21 '16 at 08:14
1 Answers
1
We can set the Title and subtitle for Toolbar programmatically like this :
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
toolbar.setTitle(getString(R.string.history));
toolbar.setSubtitle(getString(R.string.month));

Sunilkumar Ramamurthy
- 133
- 17