GithubHelp home page GithubHelp logo

space-navigation-view's Introduction

Space-Navigation-View

Android Arsenal

##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 16 Android 4.1 (JELLY BEAN).

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.0.0'

Maven:

<dependency>
  <groupId>com.github.armcha</groupId>
  <artifactId>SpaceNavigationView</artifactId>
  <version>1.0.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();
            }
        });

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: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

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.hideBudgeAtIndex(int itemIndexToHideBudge);

Hide all badges

  spaceNavigationView.hideAllBudges();

Change badge text

  spaceNavigationView.changeBadgeTextAtIndex(int itemIndexToChangeBadge, int badgeCountText);

Set your custom font

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

##Versions

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.

space-navigation-view's People

Contributors

armcha avatar subhrajyotisen avatar

Watchers

lixinyang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.