Adding action icons (just letters) to a ACToolBarLight, used as an actionbar.
This is the code I use for that:
This works fine, but the icons are too far apart and I am running out of space.
Is there any way to get these icons closer together?
RBS
This is the code I use for that:
B4X:
Sub TextToBitmapDrawable (s As String, FontSize As Float, lFontColour As Long) As BitmapDrawable
Dim bmp As Bitmap
Dim cvs As Canvas
Dim bmpD As BitmapDrawable
bmp.InitializeMutable(16dip, 16dip)
cvs.Initialize2(bmp)
Dim h As Double = cvs.MeasureStringHeight(s, lblID.Typeface, FontSize)
cvs.DrawText(s, bmp.Width / 2, bmp.Height / 2 + h / 2, lblID.Typeface, FontSize, lFontColour, "CENTER")
bmpD.Initialize(bmp)
Return bmpD
End Sub
Sub Activity_CreateMenu(Menu As ACMenu)
Dim item As ACMenuItem
Menu.Clear
item = Menu.Add2(1, 1, "Find", TextToBitmapDrawable("F", 16, Colors.RGB(0, 0, 0)))
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
item = Menu.Add2(2, 2, "Pat", TextToBitmapDrawable("P", 16, Colors.RGB(0, 0, 255)))
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
item = Menu.Add2(3, 3, "Meds", TextToBitmapDrawable("M", 16, Colors.RGB(255, 0, 0)))
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
item = Menu.Add(4, 4, "Settings", Null)
End Sub
This works fine, but the icons are too far apart and I am running out of space.
Is there any way to get these icons closer together?
RBS