Marek Teuchner
Marek Teuchner

Reputation: 433

Android - toolbar title disappears when hidden/shown too fast

I am experiencing a weird issue. If I change the toolbar title too fast in a short interval, it magically disappears:

09-23 12:06:33.461 D/MainActivity: #ViewModel updated title to null
09-23 12:06:33.609 D/MainActivity: #ViewModel updated title to My New Title

Code:

mViewModel.getToolbarTitle().observe(this, title -> {
    Timber.d("#ViewModel updated title to %s", title);
    mToolbar.setTitle(title);
});

There should be no initial title (it is loading data from the server) and new (downloaded) one should be displayed upon loading. If the initial title is not null, it is working correctly, but I guess there is some issue with show/hide title animation.

Don't you know how to avoid this issue?

Upvotes: 0

Views: 130

Answers (1)

Intsab Haider
Intsab Haider

Reputation: 3561

Have you set setDisplayShowTitleEnabled to true in onCreate of the Activity?

getSupportActionBar().setDisplayShowTitleEnabled(true);

Upvotes: 1

Related Questions