armcha / space-navigation-view Goto Github PK
View Code? Open in Web Editor NEWSpace Navigation is a library allowing easily integrate fully customizable Google Spaces like navigation to your app.
Space Navigation is a library allowing easily integrate fully customizable Google Spaces like navigation to your app.
Useful for setting the CenterButton_Icon_ to an individual color.
Under certain circumstances I want to do something when one of the items is clicked, but prevent that item from being selected as the current item. Could be implemented as the onItemClick method instead of being void returning a boolean, indicating whether it wants to allow the view to switch to the clicked item or not.
I tried to work around that by setting the currently selected item back to the previous one from the click listener itself, but that doesn't work as the actual switch to the clicked item only occurs after the listener has been called.
This is probably my error so please forgive me. I notice that spaceNavigationView.setActiveSpaceItemColor(ContextCompat.getColor(this, R.color.yourColor)); does not actually update the currently selected item color. That means the following code does not work properly because the color that is set will be applied to the next selected icon. Example, Item 1 selected and Item 1's icon is Red. When Item 2 is selected, Item 2's icon is Red. When Item 3 is selected, Item 3's icon is Blue.
spaceNavigationView.setSpaceOnClickListener(new SpaceOnClickListener() {
@Override
public void onCentreButtonClick() {
}
@Override
public void onItemClick(int itemIndex, String itemName) {
Log.d("Click", Integer.toString(itemIndex));
switch (itemIndex)
{
case 0:
spaceNavigationView.setActiveSpaceItemColor(ContextCompat.getColor(getApplicationContext(), R.color.RED));
break;
case 1:
spaceNavigationView.setActiveSpaceItemColor(ContextCompat.getColor(getApplicationContext(), R.color.BLUE));
break;
case 2:
spaceNavigationView.setActiveSpaceItemColor(ContextCompat.getColor(getApplicationContext(), R.color.YELLOW));
break;
case 3:
spaceNavigationView.setActiveSpaceItemColor(ContextCompat.getColor(getApplicationContext(), R.color.GREEN));
break;
default: break;
}
}
@Override
public void onItemReselected(int itemIndex, String itemName) {
}
});
Is there a proper way to set the icon color so it updates the currently selected item color? Something like changeSpaceBackgroundColor(). Thank you for taking a look!
Thank you author!!!!!!!
Can I get six items or is it only four items available?
can I use this library with viewpager?
Hi I was wondering if it would be possible to add functionality to do custom FABs in the nav view?
I would like to implement a loading fab, such as in this library
https://github.com/JorgeCastilloPrz/FABProgressCircle
There is currently no way to change the items or even the text of the items currently shown in the navigation bar. This would be massively helpful, as I need to change the text of one of the items when the user performs a certain action, without completely rebuilding the layout.
hi
I want use space navigation with fragment.
please sample code
help me please
I was using a custom icon for the center button icon. The latest update applies a mask to the icon which is undesirable for when you want to use a custom icon. The new masking feature takes away the ability to use anything other than a solid color icon.
I will be reverting back to 1.3.0. Hopefully, there will be an option to have both in a future update. Thank you!
@Kogoro
Using spaceNavigationView.setCentreButtonIconColorFilterEnabled(false);
does not work when spaceNavigationView.setCentreButtonSelectable(true); is also used.
You mentioned that you use a custom icon, how are you able to get your custom icon to show?
I met some problems, I don't know how to solve.Just like in the picture
Add shadow along the top of the navigation bar
there is a method named hideBudges? shouldn't this be hideBadges? also Centre -> Center on method names?
It would be great to be able to set the selection index manually. Also the centrebutton should be selectable.
Reason:
In my application, the centre button is the representation for the main fragment. But the selection is always on the first item at the startup. So it would be great if I could manipulate the selection.
If you don't have time. but accept pull requests, I could give it a try though it should be easy to implement.
Now it stuck on 9+
Hi
I click on one tab then click on center button but the tab does't deactivate (change text color to gray )
thanks
please support android 14+
if one changed the icon size, via app:space_item_icon_size="24dp"
the Text will be not be centered veritcally with the icon. i guess you might need to center the TextView layout gravity instead of aligning it top.
Its completely plane background, I want to add shadow effect. Is there any function for that ?
cant change background color by code
any help
pls
Nice work,I so love your library. Please how can I add a FAB behaviour to the space navigation bar? I mean I want the space navigation view to autohide when recyclerview is scrolled up and down. Thanks and thumbs up for an awesome library.
I want to add gradient color on CentreButtonColor from drawable file from java and xml both but its not working.
I use you library with support library version 24.
when I add it to my xml, I can see the area that is belong to space navigation view, but it seems it is empty! I add spaceItems to it programmatically, but nothing happens!
Center fab button icon color not updating!
More functionalities like disable FAB or hide, or something like this.
Also something like getFab() or getFabView() to control the View like RotationAnimation.
The support libraries need to be update to 25.2.0
Thanks
spaceNavigationView.addSpaceItem(new SpaceItem("HOME", R.drawable.yourDrawable));
should support Drawables as well
Thank you for your share.
Lack of changeCenterButtonColor()
Attempting to change the center button icon results in a null exception error. The error says that the FAB has not been initiated yet. However, Space Navigation View has been initiated. Might this be a bug?
SpaceNavigationView spaceNavigationView = (SpaceNavigationView) findViewById(R.id.space);
spaceNavigationView.initWithSaveInstanceState(savedInstanceState);
spaceNavigationView.changeCenterButtonIcon(R.drawable.company_icon);
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.blankicon/com.blankicon.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.design.widget.FloatingActionButton.setImageResource(int)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.design.widget.FloatingActionButton.setImageResource(int)' on a null object reference
Thank you for taking a look!
I only want the icon color to change when a tab (or center button is click)
How do I remove the highlighting when the I click?
Hey @armcha, really liking the library!
I set up my SpaceNavigationView in the onCreate of my Activity with the same setup shown in the readme and have added bottomNav.onSaveInstanceState(outState);
in my onSaveInstanceState.
Everything looks and works great in the launched activity, SpaceOnClickListener events are returning the correct name and index for my items. But if I try to call
spaceNavigationView.showBadgeAtIndex(0,5, ContextCompat.getColor(this, R.color.cyan));
in any of the main lifecycle methods in my Activity (bottom of onCreate, onResume, onPostResume, etc.) the SpaceNavigationView throws an IndexOutOfBoundsException:
Caused by: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255) at java.util.ArrayList.get(ArrayList.java:308) at com.luseen.spacenavigation.SpaceNavigationView.showBadgeAtIndex(SpaceNavigationView.java:822) at com.proto.tangible.tagalong.ExploreActivity$override.onResume(ExploreActivity.java:193) at com.proto.tangible.tagalong.ExploreActivity$override.access$dispatch(ExploreActivity.java) at com.proto.tangible.tagalong.ExploreActivity.onResume(ExploreActivity.java:0) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1326) at android.app.Activity.performResume(Activity.java:6323) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3311) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3359) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2549) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4398) at android.app.ActivityThread.access$1000(ActivityThread.java:150) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1400) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:168) at android.app.ActivityThread.main(ActivityThread.java:5845) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
However, calling the same line some time after the Activity loads (in response to a manual click event or async task with Thread.sleep(400) works just fine for me!
Looking at the library source it seems like the SpaceNavigationView needs to have been laid out before its possible to show badges for your SpaceItems. In most situations the badge quantity to display is calculated almost instantly, so waiting for the draw is a little cumbersome
Per the material design spec this component should have a default elevation of 8dp and cast a shadow upwards on to the content above it - it doesn't seem to do that currently regardless of elevation being set in the layout or in code.
Currently i am using this:
SpaceNavigationView spaceNavigationView = (SpaceNavigationView) findViewById(R.id.space);
spaceNavigationView.initWithSaveInstanceState(savedInstanceState);spaceNavigationView.setSpaceBackgroundColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
spaceNavigationView.addSpaceItem(new SpaceItem("HOME", R.drawable.ic_home_white_48dp));
spaceNavigationView.addSpaceItem(new SpaceItem("ANTEPRIMA", R.drawable.ic_web_white_48dp));
But when i call
spaceNavigationView.setSpaceOnClickListener(new SpaceOnClickListener() {
@OverRide
public void onCentreButtonClick() {
startActivity(new Intent(MainActivity.this, FormActivity.class));
}
...
I get the error message even if i added two working items:
java.lang.NullPointerException: Your space item count must be greater than 1 , your current items count isa : 0
Hi, I try to put a colored icon in the bar, but I only see a white silhouette, its posible to show the colored version? And how can i change the height of the icons bar? Thanks a lot!
FloatingActionButton shows as pressed when pointer leaves Issue 218956
When I use the space navigation in a layout file the preview window will throw an Exception:
java.lang.NullPointerException: Your space item count must be greater than 1 , your current items count is : 0
This makes the preview basically unsuable. Is there a way you could just show dummy items when in the preview, or can you provide items directly in the xml?
When I set the
spaceNavigationView.changeCurrentItem(0);
can't not trigger the onItemClick event.
Hello,
is it possible to make the center icon bigger? I want to fill the whole button with an icon (e.g. a circled profile image)
Thx :-)
hey,
Please add the shadow above the space view if it is possible!
Thanks.
How to add fragmentactivity?
Currently you can add space items, but you cannot remove them?
I am working on an activity which has two fragments, each fragment would have different nav icons and one has more icons than the other. I can add icons when moving to the second frag, but cannot remove nav icons when moving back to the first fragment.
please take a method to set text below icon.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.