i am unable to apply “Theme.AppCompat.NoTitleBar” and “colorPrimaryDark” status bar color property at the same time

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 17:42:44

问题


I want to hide the action bar throughout the application and also want to set the status bar color? in Appcelerator titanium.


回答1:


Please follow the official guide at https://wiki.appcelerator.org/display/guides2/Android+Action+Bar

You can either hide it in code win.activity.actionBar.hide(); in the open event and use a normal style in the theme xml or you set your parent in the theme to <style name="Theme.MyTheme" parent="Theme.AppCompat.NoTitleBar">.

Statusbar color is a theme item: <item name="android:statusBarColor">#ff0000</item>. You can add into your theme.

Here is a style I'm using as an example:

<style name="Theme.MyTheme" parent="Theme.AppCompat.NoTitleBar">
    <item name="colorPrimary">#212121</item>
    <item name="colorPrimaryDark">#000000</item>
    <item name="android:statusBarColor">#00d59e</item>
    <item name="colorAccent">#ff225c</item>
    <item name="android:textColorHint">#999999</item>
</style>

using

"Window" : {
    theme: "Theme.MyTheme",
    barColor: "#ff225c"
}



回答2:


I kept my custom theme file inside

App->Platform->Android->res->values->mytheme.xml

and my xml file looks like below and it works fine for me..

 <resources>
    <style name="Theme.MyTheme" parent="Theme.AppCompat.NoTitleBar.Fullscreen">
        <item name="buttonStyle">@style/MyButton</item>
    </style>
    <style name="MyButton" parent="Widget.AppCompat.Button">
        <item name="android:textAllCaps">false</item>
    </style>
</resources>

and in tiapp.xml file inside maifest

<application android:theme="@style/Theme.MyTheme"/>



回答3:


Try this code.May be it will help you. -

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            getWindow().setStatusBarColor(getResources().getColor(R.color.color_name));
        }


来源:https://stackoverflow.com/questions/54359386/i-am-unable-to-apply-theme-appcompat-notitlebar-and-colorprimarydark-status

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