14

How do I set the actionbar mode at runtime to not-overlay or overlay with the content at runtime? I tried using getWindow().requestFeature(Window.FEATURE_ACTIONBAR_OVERLAY) but it doesn't allow to set the mode after calling setContentView(). This can be done, as I have seen it being done in the Youtube app.

4

1 回答 1

5

尽管不一定完全符合您的要求,但一种体面的解决方法是在内容顶部创建一个与 ActionBar 高度相同的间隔视图 (android:layout_height="?android:actionBarSize")。当您想要启用覆盖模式时,将间隔的可见性设置为 View.GONE,当您想要禁用它时,将其设置为 View.VISIBLE。

于 2013-09-04T18:52:45.147 回答