Android Question Changing theme at runtime with Appcompact

trueboss323

Active Member
Licensed User
Longtime User
I read Erel's tutorial about how to change theme during the runtime. But in my case I am using the Appcompact library so it's not working very well for me. What I want to do is give the user the option to choose from different themes (Light, Dark, Blue, Purple, Green, etc) . And based on their selection would load the appropriate theme for it. What i'm guessing i need to do is create different Appcompact themes for each file. Then place those xml files inside \Objects\res\values folder. But then I wouldnt know how to load from that xml file. Any help with this?
 
I'm not at my B4A workstation right now, but I assume loading the theme file should be something simple. For example I have a file named blue.xml with this layout:
Code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Blue"
parent="Theme.AppCompact">
        <item name="colorPrimary">#0000ff</item>
        <item name="colorPrimaryDark">#0000ff</item>
        <item name="colorAccent">#FFA726</item>
        <item name="windowBackground">#FFA726</item>
        <item name="textColorPrimary">#FFA726</item>
        <item name="windowNoTitle">false</item>
    </style>
</resources>

If I wanted to try and load it I would use something like
Code:
  Dim x As XmlLayoutBuilder
   x.LoadXmlLayout(Activity, "blue")

Please correct me if I'm wrong.
 
Last edited:
Upvote 0
Im assuming the resource file is correct since im not an expert with xml files. I've seen how the theme is loaded but I'm having difficulty trying to figure out how I get the theme id using XmlLayoutBuilder for one of my files ?
 
Upvote 0
Back
Top