At my company we are using Ionic Framework and Cordova to create our mobile app, and upon starting the design of the app, we encountered an issue with the Android theme and how to set it without touching the AndroidManifest generated by Ionic build command.
Everywhere I look it is recommended to implement any customization from the config.xml file and never touch the AndroidManifest, but I cant seem to find any methods regarding the Android theme.
My question to you now: Is there a way to set the android theme for the application, for example Holo Theme, from the Config.xml without changing the AndroidManifest.xml generated?
To avoid touching the platforms directory, you could use a cordova hook. I am pretty terrible at node, but here is something that should do the trick. First
npm install elementtree
then create a sub folderafter_prepare
in the hooks folder. From there stick this code into a javascript file and change YourTheme.Honestly, this is some pretty gross code, but should give you the idea.
I know I'm late, but
cordova-custom-config
plugin made just to "update platform configuration files based on preferences and config-file data defined in config.xml."for example:
install the cordova-custom-config plugin:
cordova plugin add cordova-custom-config --save
Config.xml:
<preference name="android-manifest/application/activity/@android:theme" value="@android:style/Theme.Holo"/>
This will add the attribute "android:theme" to your AndroidManfiset --> application --> activity with the value:
@android:style/Theme.Holo
.You can use Header Color plugin:
Install the plugin:
$ ionic cordova plugin add cordova-plugin-headercolor $ npm install --save @ionic-native/header-color
Add configuration to config.xml
<preference name="HeaderColor" value="#becb29" />
https://ionicframework.com/docs/native/header-color/
You can do this now without any third party plugin since 6.3.0. Just add this to the config.xml
and for me it was also neccessary to add 'xmlns:android="http://schemas.android.com/apk/res/android" ' to the widget tag