[TIMOB-28087] Android: Add "NoTitleBar" and "Fullscreen" themes which derive from custom app theme
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-11-25T14:59:12.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 9.3.0 |
Components | Android |
Labels | android, theme |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2020-08-18T01:22:16.000+0000 |
Updated | 2020-11-25T14:59:12.000+0000 |
Description
*Summary:*
The only means of opening a window without top title bar is via its "theme" creation property set to 1 of the below. The problem with this is that the below themes inherit from Google's dark AppCompat theme and do not use the theme assi
*
"Theme.AppCompat.NoTitleBar"
* "Theme.AppCompat.NoTitleBar.Fullscreen"
* "Theme.AppCompat.Fullscreen"
The problem with the above is that the above themes inherit from Google's dark "Theme.AppCompat"
theme. If you've assigned a custom theme to the <application/>
element in the "AndroidManifest.xml", the window won't use it because you told it to use Google AppCompat derived theme instead.
*Reason this is Needed:*
Other than making it easier to remove the title bar, we also want to support Google's Material themed widgets in the near future. These widgets will throw an exception if the activity or app is not using a "Theme.MaterialComponents"
derived theme and if most developers are using the "Theme.AppCompat"
theme instead (like what our guides suggest), then the app will crash. We'll want to have developers transition off of these older Google themes.
*Recommended Solution:*
Create the following new themes...
* "Theme.Titanium.NoTitleBar"
* "Theme.Titanium.Fullscreen"
* "Theme.Titanium.Translucent.NoTitleBar"
* "Theme.Titanium.Translucent.Fullscreen"
_(We already have "Theme.Titanium.Translucent"
defined which derives from app's theme.)_
Titanium's build system will derive the above themes from the one assigned to the <application/>
in the "AndroidManifest.xml" as shown below. If a theme is not assigned, then they will derive from Titanium's default theme.
<?xml version="1.0" encoding="UTF-8"?>
<ti:app>
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:theme="@style/MyTheme"/>
</manifest>
</android>
</ti:app>
*Note:*
You can easily work-around this by setting up your own custom NoTitleBar theme like the below. This is easy to do, but doing the above makes removing title bars easier.
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- Your custom theme. -->
<style name="MyTheme" parent="@style/Theme.AppCompat.Light">
<item name="colorPrimary">#c91326</item>
<item name="colorAccent">#000000</item>
<item name="android:textColor">#FF0000</item>
<item name="android:textColorPrimary">#000000</item>
<item name="android:statusBarColor">#c91326</item>
<item name="android:navigationBarColor">#c91326</item>
</style>
<!-- Your custom theme without a title bar. -->
<style name="MyTheme.NoTitleBar" parent="@style/MyTheme">
<item name="android:windowActionBar">false</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<!-- Your custom theme without a title bar and status bar. -->
<style name="MyTheme.Fullscreen" parent="@style/MyTheme.NoTitleBar">
<item name="android:windowFullscreen">true</item>
</style>
</resources>
PR (9.3.x): https://github.com/appcelerator/titanium_mobile/pull/11921
FR Passed, waiting on Jenkins build.
*Closing ticket*. Feature verified in SDK version
9.3.0.v20201125050632
. *Test and other information can be found at: *https://github.com/appcelerator/titanium_mobile/pull/11921