Android Code Snippet Change ACMenuItem Icon Color

A simple code to change the color of icons in ACMenuItem. Code can be used also to change another else BitmapDrawable

Tags: BitmapDrwawable, Icon Color, AcMenuItem

B4X:
Sub Activity_CreateMenu(Menu As ACMenu)
    Dim bd As BitmapDrawable
    bd.Initialize(LoadBitmapResize(File.DirAssets,"hintsw.png",32dip,32dip,True))
    bd.Gravity = Gravity.CENTER
    Dim jo As JavaObject = bd
    Dim p As JavaObject
    p.InitializeStatic("android.graphics.PorterDuff.Mode")
    jo.RunMethod("setColorFilter",Array(0xffff0000,p.GetField("SRC_IN")))

    Dim item As ACMenuItem = Menu.Add2(0,0,"",bd)
    item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS  
End Sub
 
Last edited:
Top