Android Question AddMenuItem with logo file

Picon

Member
Licensed User
Hi everyone

My goal is to add a png logo to the menu bar. I experimentally moved the logo to the center using empty spaces - see code line 6:

my menu with png logo at center:
    Dim mi As B4AMenuItem = B4XPages.AddMenuItem(Me, "2")
    mi.AddToBar = True
    'mi.Bitmap = xui.LoadBitmapResize(File.DirAssets, "blue_01A.png", 129, 80, False)
    mi.Bitmap = xui.LoadBitmap(File.DirAssets, "blue.png")
     
    mi = B4XPages.AddMenuItem(Me, "                       ")
    mi.AddToBar = True
     
    mi = B4XPages.AddMenuItem(Me, "Setings")
    mi.AddToBar = True


Is there any other method to add a png file to the menu bar in the center?

The image is barely visible, and trying to resize it didn't produce the desired results. My original png file is 4084 x 2534 pixels (156KB), so it's large, and in the menu, you practically have to look at it through a magnifying glass.

Does anyone have any ideas?
 
Last edited:

TILogistic

Expert
Licensed User
Longtime User
more
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
other:
 
Upvote 0

Picon

Member
Licensed User

&TILogistic,​

thank you so much for the quick reply...
For B4A, "cs As CSBuilder" is perfect. It works and is exactly what I was looking for.

However, as always, there's always a problem:

In B4A, there's no "cs.Image" option. You can load png files from the designer, but there are only five options: Top Right #1 ... #5
None of them completely displays the image on the left or in the center.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Upload an example that demonstrates what you want to do.
 
Upvote 0

jameshouser

New Member
Hello, You can’t truly center or enlarge a PNG in the default menu bar — Android auto-scales menu icons to ~24–32 dp. To control size and position, create a custom Toolbar or Panel and add an ImageView for your logo instead.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Hello, You can’t truly center or enlarge a PNG in the default menu bar — Android auto-scales menu icons to ~24–32 dp. To control size and position, create a custom Toolbar or Panel and add an ImageView for your logo instead.
?
B4X:
AddManifestText(
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="actionBarSize">64dp</item>
    </style>
</resources>
)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…