Android Question [SOLVED] StdActionBar Color

eurojam

Well-Known Member
Licensed User
Longtime User
Hi all,
may be I don't see the wood for the trees: is it possible to change the color of the stdActionBar for different activities - I know how to change the color theme in general - but activity main should have a blue and activity two should have a red actionbar...?

Thanks in advance
stefan
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use this sub:
B4X:
Sub SetActionBarColor(Color As Int)
   Dim jo As JavaObject
   jo.InitializeContext
   Dim cd As ColorDrawable
   cd.Initialize(Color, 0)
   jo.RunMethodJO("getActionBar", Null).RunMethod("setBackgroundDrawable", Array(cd))
End Sub

If you are targeting Android 2.x devices then you should first check the SDK version with the phone library.


You can also use other types of drawables:

upload_2016-2-29_11-1-49.png
 
Upvote 0

ZenWhisk

Member
Licensed User
Longtime User
This function works fine, but in Material Design, I lose the 'elevation' shadow, is there any way to avoid that?
 
Upvote 0
Top