I have this List of themes in a database used by a desktop app.
So let's say I have the Base application theme for my android app:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowBackground">@android:color/white</item>
</style>
In the desktop App, the themes can be edited and new themes can be added. (So, it would be problematic to hardcode all the existing themes using themes.xml or styles.xml).
The Json with one of the themes look like this:
[
{
"id_temas": 1,
"tema_nome": "Padrão",
"bd_barratitulo": "#FF00308B",
"bd_fundo": "#FFD2E8EC",
"bd_titulo": "#FFFFFFFF",
"linear_1a": "#FF002E8A",
"linear_1b": "#FF0071B7",
"linear_1c": "#FF002E8A",
"linear_2a": "#4C8BC0",
"linear_2b": "#015CA3",
"linear_2c": "#024795",
"linear_2d": "#2C5198",
"linear_3a": "#000098",
"linear_3b": "#000075",
"linear_3c": "#000075",
"linear_3d": "#000082",
"person": 0
}
]
So, the question is: How can I retrieve the hex strings that I have stored in my database and apply to the android activities? The idea is that when the user logs In, the bars and backgrounds etc, get the colors from one of the database's themes list.
Very Thanks in advance.
If you want to set background color for ex try this:
currentLayout.setBackgroundColor(Color.parseColor("#FFFFFF"));
Where #FFFFFF is the string from your json