android自定义导航,一个轻量级的Android库可轻松制作漂亮的导航栏,具有大量的自定义选项...

Bubble Navigation

68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4150492d31362532422d627269676874677265656e2e7376673f7374796c653d666c617468747470733a2f2f6170692e62696e747261792e636f6d2f7061636b616765732f6761757261766b39352f6d6176656e2d7265706f2f627562626c656e617669676174696f6e2f696d616765732f646f776e6c6f61642e73766768747470733a2f2f7472617669732d63692e6f72672f6761757261766b39352f627562626c652d6e617669676174696f6e2e7376673f6272616e63683d6d617374657268747470733a2f2f696d672e736869656c64732e696f2f62616467652f416e64726f6964253230417273656e616c2d427562626c652532304e617669676174696f6e2d677265656e2e7376673f7374796c653d666c617468747470733a2f2f696d672e736869656c64732e696f2f62616467652f416e64726f69642532305765656b6c792d2532333335312d626c75652e73766768747470733a2f2f696d672e736869656c64732e696f2f62616467652f417765736f6d655f416e64726f69642d427562626c654e617669676174696f6e2d707572706c652e7376673f7374796c653d666c6174

🎉 A light-weight library to easily make beautiful Navigation Bars with a ton of

🎨 customization options.

Demos

FloatingTopBarActivity

TopBarActivity

5fbd7071097a5c88f09f13a525aa04dd.gif

e3727904fe40ffea61d3eabbee4d3b3d.gif

BottomBarActivity

EqualBottomBarActivity

2cc0d07e27dad406178378fd906d0638.gif

943a48524e45372115ab0c4f9bc4a3b1.gif

Features:

Support for API Level 16+

Highly customizable

Light weight and easy-to-use

Supports TransitionDrawable for cool state changes

2 types of NavigationView for different use cases

BubbleNavigationConstraintView: supports spread, inside and packed mode

BubbleNavigationLinearView: allows equal distribution using weight or packed mode

Bonus BubbleToggleView to create new UI components, other than navigation

Add Badges

Usage

Check out the Sample app, to see how its implemented.

Gradle

This library is available on JCenter. To use it, add the following to build.gradle

dependencies {

implementation 'com.gauravk.bubblenavigation:bubblenavigation:1.0.7'

}

XML

android:id="@+id/top_navigation_constraint"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_marginBottom="380dp"

android:background="@color/white"

android:elevation="4dp"

android:padding="12dp"

app:bnc_mode="spread">

android:id="@+id/c_item_rest"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

app:bt_active="true"

app:bt_colorActive="@color/search_active"

app:bt_colorInactive="@color/search_inactive"

app:bt_icon="@drawable/ic_restaurant"

app:bt_shape="@drawable/transition_background_drawable_restaurant"

app:bt_title="@string/restaurant"

app:bt_padding="@dimen/internal_padding"

app:bt_titlePadding="@dimen/title_padding" />

attr

Description

bnc_mode

Changes the display mode the child elements

- spread : equally distributes the child elements

- packed : elements are packed with center gravity

- inside : inside elements are equally distributed

OR

android:id="@+id/bottom_navigation_view_linear"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="@color/white"

android:elevation="8dp"

android:orientation="horizontal"

android:padding="12dp">

android:id="@+id/l_item_home"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

app:bt_active="true"

app:bt_colorActive="@color/home_active"

app:bt_colorInactive="@color/home_inactive"

app:bt_icon="@drawable/ic_home"

app:bt_shape="@drawable/transition_background_drawable_home"

app:bt_title="@string/home"

app:bt_padding="@dimen/internal_padding"

app:bt_titlePadding="@dimen/title_padding" />

Using BubbleToggleView

BubbleToggleView is designed to work as a child component for the BubbleNavigationLinearView and BubbleNavigationConstraintView. This view can be used independently for:

Custom implementation of NavigationBar

Creation of new UI components

ToggleView

attr

Description

bt_active

Sets to Active State

bt_colorActive

When in Active State, uses this color for the Icon and Title

bt_colorInctive

When in Inactive State, uses this color for the Icon and Title

bt_icon

Sets the Icon Drawable

bt_iconWidth

Updates the Icon Width

bt_iconHeigth

Updates the Icon Height

bt_title

Sets the Title Text

bt_titleSize

Updates the Tilte Text Size in sp

bt_shape

Sets the Background Drawable. Use TransitionDrawable to get fade in-out effect when toggling

bt_showShapeAlways

If true and using Normal drawable, background shape remains visible always

bt_shapeColor

Changes the tint color of the shape. N/A when using TransitionDrawable or showShapeAlways is true.

bt_duration

Sets time duration for toggle animation to complete in ms

bt_padding

Sets the internal padding in dp

bt_titlePadding

Sets the title padding in dp

bt_badgeText

Sets the text for the badge

bt_badgeTextSize

Sets the font size of the badge text

bt_badgeTextColor

Sets the text color of the badge

bt_badgeBackgroundColor

Sets the background color of the badge

Note: Normal drawables may retain the shape of each Navigation item. Setting the same drawable for each item with different bt_shapeColor properties produces a similar effect while lowering memory usage and improving performance.

Activity/Fragment

In Java

bubbleNavigation.setNavigationChangeListener(new BubbleNavigationChangeListener() {

@Override

public void onNavigationChanged(View view, int position) {

//navigation changed, do something

}

});

Or in Kotlin

navigation_view.setNavigationChangeListener { view , position ->

//navigation changed, do something here

}

Method

Description

void setCurrentActiveItem(int position)

Changes the current active state for the navigation view

void setTypeface(Typeface typeface)

Updates the typeface of the text

void setNavigationChangeListener(BubbleNavigationChangeListener listener)

Sets the navigation change listener

int getCurrentActiveItemPosition()

Returns the current active position

void setBadgeValue(int position, String value)

Updates the corresponding badge text value

Contribute

Users are welcome to suggest ideas or feature requests, or report bugs and issues here

I am always open to new suggestions and good contributions.

Contact

Feel free to reach out to me at gauravkcs50@gmail.com

License:

Copyright 2019 Gaurav Kumar

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.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值