Android Question [SOLVED] StdActionBar Color

Discussion in 'Android Questions' started by eurojam, Feb 29, 2016.

  1. eurojam

    eurojam Well-Known Member Licensed 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
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You can use this sub:
    Code:
    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
     
  3. eelias

    eelias Active Member Licensed User

    I am still using B4A 3.82, is it possible to have this same solution for it?
     
  4. DonManfred

    DonManfred Expert Licensed User

    Time to update B4A :D
     
    eurojam likes this.
  5. ZenWhisk

    ZenWhisk Member Licensed User

    This function works fine, but in Material Design, I lose the 'elevation' shadow, is there any way to avoid that?
     
  6. Erel

    Erel Administrator Staff Member Licensed User

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice