英文:
Action Bar title and menu disappear when replacing fragment, after updating from targetSdkVersion 30 to 33
问题
应用程序在升级之前运行正常。一些库也进行了更新,但将库还原不似乎能解决问题。
我觉得这可能与片段事务和片段/活动的生命周期有关。
当片段事务提交时,操作栏(作为支持操作栏的MaterialToolbar)变为空白。
在升级后,有人遇到了这种行为吗?
英文:
The application worked fine until I had to upgrade. Some libraries were updated also, but reverting the libraries back don't seem to fix it.
It seems to me that it is something related with the fragment transaction and the lifecycle of the fragment/activity.
When the fragment transaction is committed, the action bar (MaterialToolbar as support action bar) becomes blank.
Did anybody encountered this behaviour after upgrading?
答案1
得分: 0
问题出在操作栏存在于片段布局文件而不是活动布局文件中。这在之前是有效的。
将操作栏(MaterialToolbar作为支持操作栏)移到活动布局中可以解决这个问题,但会引入其他问题。
英文:
The issue was due to the ActionBar being present in the fragment layout file instead of the activity one. This used to work before.
Moving the ActionBar (MaterialToolbar as support action bar) to the activity layout fixes the issue, but it introduces other problems.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论