Action Bar标题和菜单在从targetSdkVersion 30更新到33后,替换片段时消失。

huangapple go评论62阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年3月31日 19:43:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/75898143.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定