CollapsingToolbarLayout.setTitle(title) does not work after changing appbarLayout

I was able to solve this issue using the following answer provided by @DanielPersson at how to pin title in Toolbar inside CollapsingToolbarLayout:

collapsingToolbarLayout.setTitleEnabled(false);
toolbar.setTitle("My Title");

By calling setTitleEnabled(false);, the title appeared in the toolbar.


It is the same as setting title in a normal toolbar.

In your xml layout file for collapsing toolbar, inside the CollapsingToolbarLayout you'll have a normal toolbar (android.support.v7.widget.Toolbar) for which you should set an id (android:id="@+id/toolbar"). Find this toolbar using the id in your java class and set the title.

  mToolbar = findViewById(R.id.toolbar);
  setSupportActionBar(mToolbar);
  getSupportActionBar().setTitle(R.string.home);

Just add this line of code to the CollapsingToolbarLayout tag in your xml layout.

app:title="Title You Want"

It works If you want to Change the collapsingToolbarLayout title.