B4A Library SpaceNavigation

bluedude

Well-Known Member
Licensed User
Longtime User
I'm running the sample but unfortunately it does not look like the sample screenshots you shared. Any cooler samples?
 

fredo

Well-Known Member
Licensed User
Longtime User
Awesome, you think we could have a compass for the middle button?
You can put every icon you like in the items or the centre button.
Just copy the Android Vector Drawable XML-file to the folder "Resource.Navigation/drawable" in your project and use the filename (without ".xml")
B4X:
SpaceNavigationView1.CentreButtonIcon = "compass"

a) Open this: https://materialdesignicons.com/
b) Enter the name of the icon you are searching for
c) Click on one of the found icons
d) Click on "</>" and then on "View Vector Drawable"
e) In the appearing Viewer with the XML text click on "Download"
f) copy the downloaded XML-file to the Folder "Resource.Navigation/drawable"
 

Attachments

  • compass.xml
    490 bytes · Views: 359

bluedude

Well-Known Member
Licensed User
Longtime User
Cool, that works. No I need to see how I can rotate the vector in an easy way.
 

bluedude

Well-Known Member
Licensed User
Longtime User
And how can we support below API level 23? Do we need to have extra PNG's in drawable?
 

bluedude

Well-Known Member
Licensed User
Longtime User
I tried a few things and I see the following issues with this navigation bar:

- it does not align correctly to the bottom on 7 inch or bigger devices;
- you cannot seem to change icons on the fly;
-
 

bluedude

Well-Known Member
Licensed User
Longtime User
And on phones it seems to be aligned incorrectly too. The middle circle button has a small flat tire.

Good news is that it works on Android 4.3 etc
 

DonManfred

Expert
Licensed User
Longtime User
Good news is that it works on Android 4.3 etc
What android version does the device have where it does not work correctly?

Quote from Github project
The current minSDK version is API level 14 Android 4.0 (ICE CREAM SANDWICH).
 

bluedude

Well-Known Member
Licensed User
Longtime User
API level 19 and above. On a 7 inch device there is a white line below the navigation and on my phones the middle icon has a small "flat" tire effect. All these devices are above level 19.
 

MarcoRome

Expert
Licensed User
Longtime User
Hi Don .
in pictures i see:


what i must do for add number 4 up icon ?
Thank you
 

inakigarm

Well-Known Member
Licensed User
Longtime User
Hi Don .
in pictures i see:
View attachment 50038

what i must do for add number 4 up icon ?
Thank you
If I remember well, you'll have to play with badge items:
B4X:
changeBadgeTextAtIndex (badgeIndex As Int, badgeText As Int)
Change badge text at index
badgeIndex: target index
badgeText: badge count text to change

Hiding all available badges
B4X:
hideBudgeAtIndex (index As Int)
Hide badge at index
index: badge index

B4X:
showBadgeAtIndex (itemIndex As Int, badgeText As Int, badgeColor As Int)

Show badge at index
itemIndex: index
badgeText: badge count text[/CODE]
 

inakigarm

Well-Known Member
Licensed User
Longtime User
Works here (click on center button to show badge)

B4X:
#Region  Project Attributes
    #ApplicationLabel:spacenavigation
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: True
    #IncludeTitle: False
#End Region

#AdditionalRes: ..\Resource.Navigation
#Extends: android.support.v7.app.AppCompatActivity

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    'Dim l as Label
   
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private SpaceNavigationView1 As SpaceNavigationView
    Dim lbl As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    lbl.Initialize("")
   
    Activity.LoadLayout("Layout1")
   
    SpaceNavigationView1.ActiveSpaceItemColor = Colors.Red
    SpaceNavigationView1.CentreButtonColor = Colors.blue
    SpaceNavigationView1.CentreButtonIcon = "settings_1"
   
    Dim item As SpaceItem
    item.Initialize("Account","account")   
    SpaceNavigationView1.addSpaceItem(item)
    Dim item As SpaceItem
    item.Initialize("Bell","bell")   
    SpaceNavigationView1.addSpaceItem(item)

    Dim item As SpaceItem
    item.Initialize("Camera","camera")   
    SpaceNavigationView1.addSpaceItem(item)
    Dim item As SpaceItem
    item.Initialize("B4A","heart")   
    SpaceNavigationView1.addSpaceItem(item)
    SpaceNavigationView1.showIconOnly
     
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub SpaceNavigationView1_onCentreButtonClick()
    Log("SpaceNavi_onCentreButtonClick()")
    lbl.Text=$"SpaceNavi_onCentreButtonClick()"$
    SpaceNavigationView1.showBadgeAtIndex(1,1,Colors.Red)
End Sub
Sub SpaceNavigationView1_onItemClick(index As Int, text As String)
    'IF SpaceNavigationView1.
    Log($"SpaceNavi_onItemClick(${index},${text})"$)
    lbl.Text=$"SpaceNavi_onItemClick(${index},${text})"$
End Sub
 

MarcoRome

Expert
Licensed User
Longtime User

Yes if you insert in event:

SpaceNavigationView1_onCentreButtonClick()
SpaceNavigationView1_onItemClick(index As Int, text As String)

work but if you insert this in create event ( i want see this when i open the app ) i have this error:


Any solution ?
Thanks again
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…