• Stars
    star
    1,991
  • Rank 22,357 (Top 0.5 %)
  • Language
    Java
  • Created almost 8 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Space Navigation is a library allowing easily integrate fully customizable Google Spaces like navigation to your app.

Space-Navigation-View

Android Arsenal Buy Me a Coffee at ko-fi.com

Introduction


Space Navigation is a library allowing easily integrate fully customizable Google [Spaces][1] like navigation to your app. [1]: https://play.google.com/store/apps/details?id=com.google.android.apps.social.spaces

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

Download sample [apk][7] [7]: https://github.com/armcha/Space-Navigation-View/raw/master/SpaceNavigationView.apk

YouTube demos

Demo 1

Demo 1

Demo 2

Demo 2

Download magic


Gradle:

compile 'com.github.armcha:SpaceNavigationView:1.6.0'

Maven:

<dependency>
  <groupId>com.github.armcha</groupId>
  <artifactId>SpaceNavigationView</artifactId>
  <version>1.6.0</version>
  <type>pom</type>
</dependency>

Setup and usage


Add the Space Navigation view to your layout

 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
     android:layout_height="match_parent">
     
      <...View
             ....
             android:layout_marginBottom="@dimen/view_bottom_margin" />
             
      <com.luseen.spacenavigation.SpaceNavigationView
             android:id="@+id/space"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:layout_gravity="bottom"/>
             
 </FrameLayout>

Add Space Navigation items.

   SpaceNavigationView spaceNavigationView = (SpaceNavigationView) findViewById(R.id.space);
   spaceNavigationView.initWithSaveInstanceState(savedInstanceState);
   spaceNavigationView.addSpaceItem(new SpaceItem("HOME", R.drawable.yourDrawable));
   spaceNavigationView.addSpaceItem(new SpaceItem("SEARCH", R.drawable.yourDrawable));

Use initWithSaveInstanceState(savedInstanceState) and override onSaveInstanceState if you want to keep selected item position and badge on device rotation

       @Override
       protected void onSaveInstanceState(Bundle outState) {
           super.onSaveInstanceState(outState);
           spaceNavigationView.onSaveInstanceState(outState);
       }

Set onClick listener

   spaceNavigationView.setSpaceOnClickListener(new SpaceOnClickListener() {
            @Override
            public void onCentreButtonClick() {
               Toast.makeText(MainActivity.this,"onCentreButtonClick", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onItemClick(int itemIndex, String itemName) {
               Toast.makeText(MainActivity.this, itemIndex + " " + itemName, Toast.LENGTH_SHORT).show();
            }
            
             @Override
             public void onItemReselected(int itemIndex, String itemName) {
               Toast.makeText(MainActivity.this, itemIndex + " " + itemName, Toast.LENGTH_SHORT).show();           
            }
        });

Set onLongClick listener

    spaceNavigationView.setSpaceOnLongClickListener(new SpaceOnLongClickListener() {
            @Override
            public void onCentreButtonLongClick() {
                Toast.makeText(MainActivity.this,"onCentreButtonLongClick", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onItemLongClick(int itemIndex, String itemName) {
                Toast.makeText(MainActivity.this, itemIndex + " " + itemName, Toast.LENGTH_SHORT).show();
            }
        });

Customize

Customize with xml

 <com.luseen.spacenavigation.SpaceNavigationView
        android:id="@+id/space"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="bottom"
        app:active_item_color="@color/colorAccent"
        app:centre_button_color="@color/centre_button_color"
        app:inactive_item_color="@color/white"
        app:space_background_color="@color/colorPrimary"
        app:centre_button_icon="@drawable/my_drawable"
        app:space_item_icon_size="@dimen/space_item_icon_default_size"
        app:space_item_icon_only_size="@dimen/space_item_icon_only_size"
        app:space_item_text_size="@dimen/space_item_text_default_size" />
Attribute Description
active_item_color item color when selected
inactive_item_color item color when unselected
centre_button_color centre circle button color
space_background_color space view background color
space_item_icon_size item icon size
space_item_icon_only_size item icon size on showIconOnly() mode
space_item_text_size item text size
centre_button_icon allow changing center icon from layout

Change space navigation background

spaceNavigationView.setSpaceBackgroundColor(ContextCompat.getColor(this, R.color.yourColor));

Change centre button icon

spaceNavigationView.setCentreButtonIcon(R.drawable.yourDrawable);

Change centre button background color

spaceNavigationView.setCentreButtonColor(ContextCompat.getColor(this, R.color.yourColor));

Change selected item text and icon color

spaceNavigationView.setActiveSpaceItemColor(ContextCompat.getColor(this, R.color.yourColor));

Change unselected item text and icon color

spaceNavigationView.setInActiveSpaceItemColor(ContextCompat.getColor(this, R.color.yourColor));

Change space item icon size

spaceNavigationView.setSpaceItemIconSize((int) getResources().getDimension(R.dimen.yourDimen));

Change space item icon size when showIconOnly(); mode activated

spaceNavigationView.setSpaceItemIconSizeInOnlyIconMode((int) getResources().getDimension(R.dimen.yourDimen));

Change space item text size

spaceNavigationView.setSpaceItemTextSize((int) getResources().getDimension(R.dimen.yourDimen));

Hide items text and show only icons

spaceNavigationView.showIconOnly();

Hide items icon and show only texts

spaceNavigationView.showTextOnly();

You can change selected item programmatically

spaceNavigationView.changeCurrentItem(int tabIndexToSelect);

Show badge

spaceNavigationView.showBadgeAtIndex(int itemIndexToShowBadge, int badgeCountText, int badgeBackgroundColor);

Hide badge at index

spaceNavigationView.hideBadgeAtIndex(int itemIndexToHideBadge);

Hide all badges

spaceNavigationView.hideAllBadges();

Change badge text

spaceNavigationView.changeBadgeTextAtIndex(int itemIndexToChangeBadge, int badgeCountText);

Set your custom font

spaceNavigationView.setFont(Typeface.createFromAsset(getAssets(), "your_cutom_font.ttf"));

Set centre button pressed state color

spaceNavigationView.setCentreButtonRippleColor(ContextCompat.getColor(this, R.color.yourColor));

Now you can change centre button icon if space navigation view already set up

spaceNavigationView.changeCenterButtonIcon(R.drawable.yourDrawable);

Also you can change item text and icon if space navigation view already set up

spaceNavigationView.changeItemTextAtPosition(0, "NEW TEXT");
spaceNavigationView.changeItemIconAtPosition(1, R.drawable.yourDrawable);

Now you can change space navigation view background color if it already set up

 spaceNavigationView.changeSpaceBackgroundColor(ContextCompat.getColor(context,R.color.yourColor));

If you want to show full badge text or show 9+

spaceNavigationView.shouldShowFullBadgeText(true);

Set centre button icon color

spaceNavigationView.setCentreButtonIconColor(ContextCompat.getColor(context,R.color.yourColor));

If you want to disable default white color filter, just call

spaceNavigationView.setCentreButtonIconColorFilterEnabled(false);

Add recycler view scroll behavior

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.luseen.spacenavigationview.MainActivity">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <com.luseen.spacenavigation.SpaceNavigationView
        android:id="@+id/space"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        app:layout_behavior="com.luseen.spacenavigation.SpaceNavigationViewBehavior" />
</android.support.design.widget.CoordinatorLayout>

##Versions

##1.6.0

  • Added saving translation height on rotation. Thanks to akiraspeirs
  • Fixed requestLayout being improperly called. Thanks to akiraspeirs
  • Fixed inActiveCentreButtonIconColor not being used initially. Thanks to nextdimension
  • Fixed issue #41

1.5.0

  • Added SpaceNavigationViewBehavior
  • Fixed issue #32

1.4.2

  • Fixed issue #34

1.4.1

1.4.0

  • Added method do disable centre button default color filter
  • Fixed issue #25

1.3.2

  • Added method setCentreButtonIconColor #17

1.3.1

  • Added method shouldShowFullBadgeText
  • Fixed issue #16 , #18

1.3.0

  • Added SpaceOnLongClickListener
  • Added changeSpaceBackgroundColor method
  • Fixed rendering problem when view is in edit mode

1.2.0

  • Fixed centre button issue
  • Added API 14+ support

1.1.0

  • Added changeItemTextAtPosition, changeItemIconAtPosition, changeCenterButtonIcon,setCentreButtonRippleColor methods
  • Now you can set onItemReselect listener

1.0.0

  • Initial release

Apps using the Space Navigation View

Kindly please let me know if you used or planning to use the library in your projects

##Project development Some crazy [pics][8] [8]: https://github.com/armcha/Space-Navigation-View/tree/master/development

Contact

Pull requests are more than welcome. Please fell free to contact me if there is any problem when using the library.

License

  Space Navigation library for Android
  Copyright (c) 2016 Arman Chatikyan (https://github.com/armcha/Space-Navigation-View).
  
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

More Repositories

1

AutoLinkTextView

AutoLinkTextView is TextView that supports Hashtags (#), Mentions (@) , URLs (http://), Phone and Email automatically detecting and ability to handle clicks.
Java
1,122
star
2

LuseenBottomNavigation

BottomNavigationView Designed according Google guideLine
Java
1,016
star
3

Ribble

Simple Dribbble Client using Dribbble API, fully written in Kotlin 😱 ❤️
Kotlin
867
star
4

ElasticView

Elastic view is a regular CardView, which can flex from user touches
Kotlin
597
star
5

ColoredShadowImageView

ColoredShadowImageView allows you to create a beautiful shadow around the image based on corresponding area colors.
Kotlin
464
star
6

PlayTabLayout

PlayTabLayout is a tab layout very similar to Google Play tab layout. The main feature is that ripple shows in a particular place where user taps.
Kotlin
328
star
7

Vertical-Intro

Vertical intro allows you to integrate material vertical intro to your app
Java
320
star
8

AutoLinkTextViewV2

AutoLinkTextView is a TextView that supports automatic detection of Hashtags (#), Mentions (@) , URLs (http://), Phone Nubers and emails
Kotlin
267
star
9

MVP-Architecture-Components

This is a sample project, showing the connection between Android Architecture Components and MVP pattern.
Java
140
star
10

DebugBanner

Debug banner lib allows you to attach debug (🐛) banner on all your activities, just by one line of code.
Kotlin
59
star
11

MotionLayout_youtube_animation

Kotlin
56
star
12

MotionLayout_example

Kotlin
54
star
13

DateHelper

Simple dateHelper, which can help you to make your life easier. Just give the date to dateHelper and get it in different formats.
Java
40
star
14

Kadapter

Kotlin
38
star
15

Screenshot-observer

Java
37
star
16

logger

Logger is simple library, which will help you to find your logs easily.
Java
24
star
17

SimplePermissions

This library allows you easily implement Android marshmallow permissions. The list of permissions, if I miss any permission please add and send me pull request.
Java
23
star
18

Easy-Fragment-Argument

This library will help you to pass and receive fragment arguments in easier way
Java
17
star
19

KotlinMultiplatformSample

Kotlin
13
star
20

Firebase-notification-android-client

Java
12
star
21

Firbase-notification-server-php

PHP
10
star
22

Meet-My-App

Java
8
star
23

MaterialTabs

Java
5
star
24

EventsWidget

Kotlin
3
star
25

RecyclerView

Java
2
star
26

room_database_sample

Java
2
star
27

AnimatedBottomBar

Kotlin
1
star
28

AwesomeRepo

Kotlin
1
star
29

MPV_architecture_adaptation

This is the second version of MPV architecture adaptation
Kotlin
1
star
30

RateMyApp

1
star
31

summer_school

Java
1
star
32

ActivityResult

Kotlin
1
star
33

Babylon

Java
1
star