Space-Navigation-View

项目地址: armcha/Space-Navigation-View

Introduction


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

 

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

Download sample apk

YouTube demos

Demo 1

Demo 2

Download magic


Gradle:

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

Maven:

  com.github.armcha  SpaceNavigationView  1.4.1  pom

Setup and usage


Add the Space Navigation view to your layout

       <...View             ....             android:layout_marginBottom="@dimen/view_bottom_margin" />       

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

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

Versions

1.4.1

  • Changing center icon from layout
  • Fixed issue #29 Thanks to ankitpopli1891

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

  • WiFi FTP Server +File Transfer

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

Project development

Some crazy pics

Contact

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

  • Email: armcha01@gmail.com
  • Facebook: https://web.facebook.com/chatikyana
  • Google +: https://plus.google.com/112011638040018774140
  • Website: http://luseen.com/

更多相关文章

  1. Android(安卓)Layout Tricks #3: Optimize with stubs
  2. android 获取wifi信息
  3. RN填坑之旅
  4. android小项目demo2
  5. 如何创建一个安卓项目
  6. 关于iOS项目开发控制
  7. IP地址获取
  8. Android实现异步加载图片(转)
  9. (转)10 Android(安卓)NDK Tips

随机推荐

  1. “360给奔驰挖了19个漏洞”,车联网给***留
  2. JavaScript:演示Ajax的get和post请求,练习
  3. PyCharm版本有哪些?是否免费?
  4. 通过Windows预读取文件找寻***者的蛛丝马
  5. 在Docker中运行特权容器很危险!!!
  6. 通过keep-alive实现了解vue组件实现原理(3
  7. Python中的IDLE是什么?常用功能介绍!
  8. 浅谈Web安全常见问题
  9. 最新整理:iOS面试题-面试常问问题(一)
  10. centos 7.6 yum搭建open***服务端以及客