Android Question Title bar color problem

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Hi, Im trying to use the manifest to change the title background as Erel shows in https://www.b4x.com/android/forum/threads/theme-colors.87716/
Ive copied the manifest lines to my manifest and compile and nothing happens, then reading the manifest I realized that I have another theme setting that comes from the biometric manifest modification, I think its overriden the first one.
Then I tried deleting the biometric theme lines but when the app runs it halts.
How to solve this?
This is my manifest:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="17" android:targetSdkVersion="30"/>
<supports-screens android:largeScreens="true"
android:xlargeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:versionCode="1"
android:versionName="2"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'SetApplicationAttribute(android:theme, "@android:style/Theme:Holo")
'End of default text.

AddManifestText(
<uses-feature android:name="android.hardware.telephony"
android:required="false" />)

AddPermission(android.permission.READ_PHONE_STATE)
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)

'Theme
'SetApplicationAttribute(android:theme, "@android:style/Theme.Holo.Light")
SetApplicationAttribute(android:theme, "@style/LightTheme")
CreateResource(values, colors.xml,
<resources>
<color name="actionbar">#FFF4C961</color>
<color name="statusbar">#FFF7B207</color>
<color name="textColorPrimary">#FF000000</color>
<color name="navigationBar">#FFF4C961</color>
</resources>
)
CreateResource(values-v20, theme.xml,
<resources>
<style name="LightTheme" parent="@android:style/Theme.Material.Light">
<item name="android:colorPrimary">@color/actionbar</item>
<item name="android:colorPrimaryDark">@color/statusbar</item>
<item name="android:textColorPrimary">@color/textColorPrimary</item>
<item name="android:navigationBarColor">@color/navigationBar</item>
</style>
</resources>
)
CreateResource(values-v14, theme.xml,
<resources>
<style name="LightTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/CustomActionBarStyle</item>
</style>
<style name="CustomActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">@color/actionbar</item>
</style>
</resources>
)

'biometric
AddPermission(android.permission.USE_BIOMETRIC)
AddPermission(android.permission.USE_FINGERPRINT)
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
CreateResource(values, theme.xml,
<resources>
<style name="MyAppTheme" parent="Theme.AppCompat.Light">
</style>
</resources>
)

'FirebaseAdmob2
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile (Macro, FirebaseAdMob.FirebaseAds)
AddReplacement($ADMOB_APP_ID$, ca-app-pub-9803933366182977~6328973890)
SetApplicationAttribute(android:usesCleartextTraffic, "true")

'Billing
CreateResourceFromFile(Macro, GooglePlayBilling.GooglePlayBilling)
 

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Ok, sory , this is my manifest, whats wrong?
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="17" android:targetSdkVersion="30"/>
<supports-screens android:largeScreens="true"
android:xlargeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:versionCode="1"
android:versionName="2"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'SetApplicationAttribute(android:theme, "@android:style/Theme:Holo")
'End of default text.

AddManifestText(
<uses-feature android:name="android.hardware.telephony"
android:required="false" />)

AddPermission(android.permission.READ_PHONE_STATE)
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)

'Theme
'SetApplicationAttribute(android:theme, "@android:style/Theme.Holo.Light")
SetApplicationAttribute(android:theme, "@style/LightTheme")
CreateResource(values, colors.xml,
<resources>
<color name="actionbar">#FFF4C961</color>
<color name="statusbar">#FFF7B207</color>
<color name="textColorPrimary">#FF000000</color>
<color name="navigationBar">#FFF4C961</color>
</resources>
)
CreateResource(values-v20, theme.xml,
<resources>
<style name="LightTheme" parent="@android:style/Theme.Material.Light">
<item name="android:colorPrimary">@color/actionbar</item>
<item name="android:colorPrimaryDark">@color/statusbar</item>
<item name="android:textColorPrimary">@color/textColorPrimary</item>
<item name="android:navigationBarColor">@color/navigationBar</item>
</style>
</resources>
)
CreateResource(values-v14, theme.xml,
<resources>
<style name="LightTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/CustomActionBarStyle</item>
</style>
<style name="CustomActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">@color/actionbar</item>
</style>
</resources>
)

'biometric
AddPermission(android.permission.USE_BIOMETRIC)
AddPermission(android.permission.USE_FINGERPRINT)
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
CreateResource(values, theme.xml,
<resources>
<style name="MyAppTheme" parent="Theme.AppCompat.Light">
</style>
</resources>
)

'FirebaseAdmob2
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile (Macro, FirebaseAdMob.FirebaseAds)
AddReplacement($ADMOB_APP_ID$, ca-app-pub-9803933366182977~6328973890)
SetApplicationAttribute(android:usesCleartextTraffic, "true")

'Billing
CreateResourceFromFile(Macro, GooglePlayBilling.GooglePlayBilling)
 
Upvote 0

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
I cant use the AppCompat way because I have many many Activities, each one with many AddMenuItems and so on, I can do all the activities again adding the
ACToolBarLight1.Color = 0xff039be5 and all the code to use it.
Is there any way to use the way the first example does?

Ive tried this but it does not work:
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="17" android:targetSdkVersion="30"/>
<supports-screens android:largeScreens="true"
    android:xlargeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
     android:versionCode="1"
    android:versionName="2"   
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'SetApplicationAttribute(android:theme, "@android:style/Theme:Holo")
'End of default text.

AddManifestText(
<uses-feature android:name="android.hardware.telephony"
    android:required="false" />)
    
AddPermission(android.permission.READ_PHONE_STATE)
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)

'Theme
'SetApplicationAttribute(android:theme, "@android:style/Theme.Holo.Light")
'SetApplicationAttribute(android:theme, "@style/LightTheme")

'biometric
AddPermission(android.permission.USE_BIOMETRIC)
AddPermission(android.permission.USE_FINGERPRINT)

SetApplicationAttribute(android:theme, "@android:style/Theme.Holo.Light")
CreateResource(values, colors.xml,
<resources>
   <color name="actionbar">#ff039be5</color>
   <color name="statusbar">#ff006db3</color>
   <color name="textColorPrimary">#ffffffff</color>
   <color name="navigationBar">#ff006db3</color>
</resources>
)

'FirebaseAdmob2
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile (Macro, FirebaseAdMob.FirebaseAds)
AddReplacement($ADMOB_APP_ID$, ca-app-pub-9803933366182977~6328973890)
SetApplicationAttribute(android:usesCleartextTraffic, "true")

'Billing
CreateResourceFromFile(Macro, GooglePlayBilling.GooglePlayBilling)
 
Upvote 0

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Ok, Ive modified keeping AppComptat, I can change statusbar color but not the actionbar color. It stays always white.
Any idea?
B4X:
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
CreateResource(values, colors.xml,
<resources>
    <color name="statusbar">#FF8d9669</color>
    <color name="actionbar">#FFdde5aa</color>
    <color name="textColorPrimary">#FF000000</color>
    <color name="navigationBar">#FFdde5aa</color>
</resources>
)
CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.Light">
         <item name="android:colorPrimaryDark">@color/statusbar</item>
         <item name="android:colorPrimary">@color/actionbar</item>
         <item name="android:textColorPrimary">@color/textColorPrimary</item>
         <item name="android:navigationBarColor">@color/navigationBar</item>
    </style>
</resources>
)
 
Last edited:
Upvote 0

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Thanks, is there any way to add the app icon before the title?
 

Attachments

  • WhatsApp Image 2021-04-27 at 11.21.02.png
    WhatsApp Image 2021-04-27 at 11.21.02.png
    80.5 KB · Views: 115
Upvote 0

IndieDev

Active Member
Licensed User
HI,
This is the only option I can think of now.
The manifest code I had used.
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="29"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.

'##########################################
'### Set Holo Light DarkActionBar theme ###
'##########################################
SetApplicationAttribute(android:theme, "@style/HoloLightTheme")
CreateResource(values, colors.xml,
    <resources>
        <color name="actionbar">#ff039be5</color>
        <color name="statusbar">#ff006db3</color>
        <color name="textColorPrimary">#ff000000</color>
        <color name="navigationBar">#ff006db3</color>
    </resources>
)

CreateResource(values-v20, theme.xml,
    <resources>
        <style name="HoloLightTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
             <item name="android:colorPrimary">@color/actionbar</item>
             <item name="android:colorPrimaryDark">@color/statusbar</item>
             <item name="android:textColorPrimary">@color/textColorPrimary</item>
             <item name="android:navigationBarColor">@color/navigationBar</item>
        </style>
    </resources>
)

CreateResource(values-v14, theme.xml,
    <resources>
        <style name="HoloLightTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
            <item name="android:actionBarStyle">@style/CustomActionBarStyle</item>
        </style>
        <style name="CustomActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
            <item name="android:background">@color/actionbar</item>
        </style>
    </resources>
)
'##########################################

Sorry can't help more than this.
Right now I'm admitted in a hospital with covid infection. Recovering.

Hope it works out for you.

Regards.
 
Upvote 0
Top