728x90
I found a solution (thanks to user1506104) to changing the toolbar's title, which did not use getSupportActionBar().setTitle().
CollapsingToolbarLayout toolbarLayout = findViewById(R.id.toolbar_layout);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mViewModel.getValue().observe(this, mValue -> {
toolbarLayout.setTitle(mValue); });
Where R.id.toolbar_layout is the CollapsingToolbarLayout that parents R.id.toolbar in the activity's respective layout resource.
I do not know why it works unfortunately.
Reference
728x90
'Dev > Android' 카테고리의 다른 글
[Android] 내부저장(Internal Storage) 사용법 (0) | 2020.08.19 |
---|---|
[Android] ProgressDialog Deprecated 대체품 (0) | 2020.07.08 |
[Android] Android 11 (R) - 삼성 OS 업데이트 대상 기기 (0) | 2020.06.26 |
[Android] 중첩 Fragment 제어 (0) | 2020.06.24 |
[Android] Toolbar setTitle 타이틀 설정 변경 (0) | 2020.06.24 |