Android Question How to add additional images to Action Bar?

tseyfarth

Member
Licensed User
Longtime User
Hello,

I currently have a hamburger image on the Action Bar, along with the app Title. I would like to add another image, my logo, to the same bar but on the right side instead of the left.

Here's the current code:
B4X:
HamburgerIcon = xui.LoadBitmapResize(File.DirAssets, "hamburger.png", 32dip, 32dip, True)
AxcysLogo = xui.LoadBitmapResize(File.DirAssets, "AxcysICONWhole.png", 32dip, 32dip, True)


B4XPages.SetTitle(Me, "Axcys Touchless Entry")

This is the code to add the hamburger to the Action Bar
Page Created:
        B4XPages.GetManager.ActionBar.RunMethod("setDisplayHomeAsUpEnabled", Array(True))
        Dim bd As BitmapDrawable
        bd.Initialize(HamburgerIcon)
        B4XPages.GetManager.ActionBar.RunMethod("setHomeAsUpIndicator", Array(bd))

B4X:
Private Sub B4XPage_Appear
    #If B4A
        B4XPages.GetManager.ActionBar.RunMethod("setDisplayHomeAsUpEnabled", Array(True))
        Dim bd As BitmapDrawable
        bd.Initialize(HamburgerIcon)
'        bd.Initialize(AxcysLogo)
        B4XPages.GetManager.ActionBar.RunMethod("setHomeAsUpIndicator", Array(bd))
    #End If
End Sub

The code above only allows one or the other bitmaps to be displayed and only on the left side.

How can I add the logo to the right side of the App Title?

Thanks!
Tim
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Hello,

I currently have a hamburger image on the Action Bar, along with the app Title. I would like to add another image, my logo, to the same bar but on the right side instead of the left.

Here's the current code:
B4X:
HamburgerIcon = xui.LoadBitmapResize(File.DirAssets, "hamburger.png", 32dip, 32dip, True)
AxcysLogo = xui.LoadBitmapResize(File.DirAssets, "AxcysICONWhole.png", 32dip, 32dip, True)


B4XPages.SetTitle(Me, "Axcys Touchless Entry")

This is the code to add the hamburger to the Action Bar
Page Created:
        B4XPages.GetManager.ActionBar.RunMethod("setDisplayHomeAsUpEnabled", Array(True))
        Dim bd As BitmapDrawable
        bd.Initialize(HamburgerIcon)
        B4XPages.GetManager.ActionBar.RunMethod("setHomeAsUpIndicator", Array(bd))

B4X:
Private Sub B4XPage_Appear
    #If B4A
        B4XPages.GetManager.ActionBar.RunMethod("setDisplayHomeAsUpEnabled", Array(True))
        Dim bd As BitmapDrawable
        bd.Initialize(HamburgerIcon)
'        bd.Initialize(AxcysLogo)
        B4XPages.GetManager.ActionBar.RunMethod("setHomeAsUpIndicator", Array(bd))
    #End If
End Sub

The code above only allows one or the other bitmaps to be displayed and only on the left side.

How can I add the logo to the right side of the App Title?

Thanks!
Tim
When I converted a large project from activity based to B4XPages (not quite finished yet) I decided it might be simpler to do just make your own action bar based on a simple layout with a panel, one label and buttons for the actions. It also includes overflow panels with buttons.
Sofar seen no drawback from this yet and problems like you are describing are just not there.

RBS
 
Upvote 0
Top