Have a simple menubar (using AppCompat), setup like this:
Now I have run out of space and there is a large overflow menu, which I haven't shown in the above code. What I would like to do is move some items from the overflow menu to the above main menu
and make the main menu somehow horizontally scrollable. So swiping it from right to left will show the next group of menu items.
What would be best/simplest way to do this?
Any simple example somewhere that demonstrates this?
RBS
B4X:
Sub TextToBitmap(s As String, FontSize As Float, lFontColour As Long, _
iWidth As Int, iHeight As Int, _
TF As Typeface, strAlignment As String) As Bitmap
Dim bmp As Bitmap
Dim cvs As Canvas
bmp.InitializeMutable(iWidth * 100dip / 100, iHeight * 100dip / 100)
cvs.Initialize2(bmp)
Dim h As Double = cvs.MeasureStringHeight(s, TF, FontSize)
cvs.DrawText(s, bmp.Width / 2, bmp.Height / 2 + h / 2, TF, FontSize, lFontColour, strAlignment)
Return cvs.Bitmap
End Sub
#IgnoreWarnings: 11
Sub Activity_CreateMenu(Menu As ACMenu)
Dim item As ACMenuItem
Dim oIcon As BitmapDrawable
Menu.Clear
oIcon.Initialize(TextToBitmap("F", 24, Colors.RGB(0, 0, 0), 28, 24, Typeface.DEFAULT, "CENTER"))
item = Menu.Add2(1, 1, " Find", oIcon)
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
oIcon.Initialize(TextToBitmap("P", 24, Colors.RGB(0, 0, 255), 28, 24, Typeface.DEFAULT, "CENTER"))
item = Menu.Add2(2, 2, " Pat", oIcon)
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
oIcon.Initialize(TextToBitmap("D", 24, Colors.RGB(255, 0, 0), 28, 24, Typeface.DEFAULT, "CENTER"))
item = Menu.Add2(3, 3, " Drugs", oIcon)
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
oIcon.Initialize(TextToBitmap("V", 24, Colors.RGB(0, 192, 0), 28, 24, Typeface.DEFAULT, "CENTER"))
item = Menu.Add2(4, 4, " Vals", oIcon)
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
oIcon.Initialize(TextToBitmap("C", 24, Colors.RGB(255, 0, 255), 28, 24, Typeface.DEFAULT, "CENTER"))
item = Menu.Add2(5, 5, " Clin", oIcon)
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
oIcon.Initialize(TextToBitmap("B", 24, Colors.RGB(0, 224, 224), 28, 24, Typeface.DEFAULT, "CENTER"))
item = Menu.Add2(6, 6, " BP", oIcon)
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
oIcon.Initialize(TextToBitmap("M", 24, Colors.RGB(0, 0, 0), 28, 24, Typeface.DEFAULT, "CENTER"))
item = Menu.Add2(7, 7, " Map", oIcon)
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
End Sub
Now I have run out of space and there is a large overflow menu, which I haven't shown in the above code. What I would like to do is move some items from the overflow menu to the above main menu
and make the main menu somehow horizontally scrollable. So swiping it from right to left will show the next group of menu items.
What would be best/simplest way to do this?
Any simple example somewhere that demonstrates this?
RBS