Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28087] Android: Add "NoTitleBar" and "Fullscreen" themes which derive from custom app theme

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2020-11-25T14:59:12.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.3.0
ComponentsAndroid
Labelsandroid, theme
ReporterJoshua Quick
AssigneeJoshua Quick
Created2020-08-18T01:22:16.000+0000
Updated2020-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>

Comments

  1. Joshua Quick 2020-08-18

    PR (9.3.x): https://github.com/appcelerator/titanium_mobile/pull/11921
  2. Samir Mohammed 2020-09-28

    FR Passed, waiting on Jenkins build.
  3. Samir Mohammed 2020-11-25

    *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

JSON Source