How to restore Collapsing Toolbar Layout State after screen orientation change

…衆ロ難τιáo~ 提交于 2020-05-10 03:44:48

问题


I've been searching for the solution of my problem for some time and didn't find solution.

I want to restore my fragment's layout after screen orientation change. I have Collapsing Toolbar Layout with banner image. After screen rotation my toolbar is always expanded, I want to restore it's behavior. How can I achieve this?


回答1:


You should set ID to the CoordinatorLayout. It will automatically save its state. Believe me.

See here.




回答2:


Try using the following AppBarLayout method:

public void setExpanded (boolean expanded)

However, there's an Android issue addressing the behavior you reported



来源:https://stackoverflow.com/questions/32563300/how-to-restore-collapsing-toolbar-layout-state-after-screen-orientation-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!