Titanium: How to hide the actionBar in a non-Alloy project?

拟墨画扇 提交于 2020-02-07 18:56:10

问题


I have no problem hiding the action bar in an Alloy project. However, how do I do this in a non-Alloy project?

I tried this:

win.activity.actionBar.hide();

But it doesn't work.


回答1:


Via win.activity.actionBar.hide(); you can only hide the Action Bar when your window is finally opened. The main disadvantage is that sometimes you can see the Action Bar for a few milliseconds, because the window is initially created with Action Bar.

Since Titanium SDK 4.2.0 there are 4 predefined themes to hide the Action Bar:

Theme.AppCompat.NoTitleBar

Theme.AppCompat.NoTitleBar.Fullscreen

Theme.AppCompat.Translucent.NoTitleBar

Theme.AppCompat.Translucent.NoTitleBar.Fullscreen

see http://docs.appcelerator.com/platform/latest/#!/guide/Android_Themes-section-34636181_AndroidThemes-TitaniumThemes

Besides globally setting the theme in TiApp.xml (see Wang Dan's answer) one can hide the Action Bar via theme property of Ti.UI.Window.

var win = Ti.UI.createWindow({
    // ...
    theme: "Theme.AppCompat.NoTitleBar"
});

Note that this is a creation-only property, so win.theme = "Theme.AppCompat.NoTitleBar"; does not work.




回答2:


<android xmlns:android="http://schemas.android.com/apk/res/android">            
    <manifest>
        <application android:theme="@style/Theme.AppCompat.Translucent.NoTitleBar.Fullscreen"></application>
    </manifest>
</android>

Add this to TiApp.xml



来源:https://stackoverflow.com/questions/28462817/titanium-how-to-hide-the-actionbar-in-a-non-alloy-project

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