4

I am working with CollapsingToolbarLayout. I don't know any methods to pin title in Toolbar.

Is there any simple way to achieve this?

2 Answers 2

21

This solution works for me.

<android.support.design.widget.CollapsingToolbarLayout
        app:titleEnabled="false"
        ...
>
3
  • 1
    It is good to know, that this attribute does not removes or hides the title when set to false. It just disables the animation of the title.
    – roncsak
    Jan 18, 2019 at 19:44
  • Cool, this also re-enabled the subtitle!
    – MSpeed
    Apr 2, 2019 at 13:54
  • @roncsak Doesn't disable animation for me, it completely hides the title
    – DIRTY DAVE
    Jan 4, 2020 at 7:47
-1

You have to set its title manually in code.

CollapsingToolbarLayout collapsingToolbar =
              (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
      collapsingToolbar.setTitle("Title");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.