Android Question How can I change the colors and images according to the applied theme ?

mr.gedo

Member
Hello all,
Good Day,

i use this example here to change the themes inside my app and it's work fine but I have 4 questions, please

1- How can I change the theme for all activities in my app?
2- Can I change the panel or custom tools, (background color) from manifest?
3- How can I change the background image for each theme?
4- How can I know the name of the applied theme so I can use the if condition to change everything I need it at runtime

Best Regards
 

mr.gedo

Member
sorry I forget to write the example link

 
Upvote 0

mr.gedo

Member
This is not the correct solution.

Hello @Erel , thank you for your replay

Do you mean that if I use this example the application will not work well?
I found a way to apply the theme to all activities by putting the java code in Activity_Create

I don't want to change the theme at runtime, i mean when I load the activity in Activity_Create I want to check the currently applied theme, if it is dark for example I will change the background image to a dark image

I tried to know the applied theme from (Theme_Value) it shows me the number of current theme only when app is run but if i close app and open it again the theme_value = 0


This is a very complicated example and I can't use it in my app
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

mr.gedo

Member
I mean that this approach will be difficult and limited.

The way I would have done it is:
1. Never use activities. Only B4XPages.
2. Create a "theme manager" that uses different color palettes. In the Pleroma example I've used this tool to create two palettes: https://www.b4x.com/android/forum/threads/dark-light-color-palette.114513/#content

The problem is I use an old project so I can't convert it to B4XPages at this time and also I use custom transition between activities and I know it not working with B4XPages.

I thinking about saving the Theme Value and then read it again when I load the activity !!! so If this will be a correct solution for my case at this time please let me know

Your advice is appreciated
 
Upvote 0
Top