Notice: The Monaca & Onsen UI Community Forum is shutting down.
For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.
Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.
Prevent theme adaptation
-
Hi all,
Is it possible to prevent the onsen ui theme from adapting depending on which device is running the app? My goal is to have the UI look the same across all devices…
Thanks
Max
-
@maxmumford Absolutely! Utilize the utility function of Onsen which are documented here:
https://onsen.io/v2/docs/js/ons.html#method-disableAutoStyling
The following code may be overkill and the Onsen team can clarify, but this has always worked when I am forcing everything to be iOS on Android.
ons.ready(function(){ ons.disableAutoStyling(); ons.platform.select('ios'); // probably not necessary, but hey, why not. ons.forcePlatformStyling('ios'); });
-
@munsterlander Actually the one that is not necessary is
ons.forcePlatformStyling
because it’s just for testing and changing the style while the app is running :sweat_smile:
-
@Fran-Diox I need to go back and test because without the last one, I had difficulties getting the flat style for everything.
-
@munsterlander Because the other two should not be called on
ons.ready
. You need to call them right after importingonsenui
. After it’s ready it doesn’t change anymore :sweat_smile:
-
@Fran-Diox Doh! :scream_cat: Ok, that would make sense. I thought I had an issue with ons object not being available but I bet that was due to something else and I never went back to check this, because if it works and you don’t understand why, well move on to the next problem! lol.
Edit: For the record, VI is better than emacs! :bowtie:
Edit Edit: Since @Fran-Diox upvoted my post, I take this as confirmation that he believes VI is better!