android 汉堡菜单动画,ByeBurgerNavigationView

ByeBurger.svg

Bye Burger~ this is a easy way to make your title or bottom navigation hiding on scroll like this

title.gif

book.gif

webview.gif

Hiding on scroll: We wanted to provide as much content as possible on our user’s screens. Consequently, we decided to make the navigation hide on scroll, thus making more room for the content area. Scrolling up makes the navigation fade back in.

Shifting navigation : The Material Design bottom bar comes with a very slick animation, which is referred to as the Shifting navigation — when navigating between destinations the selected section icon is enlarged, moving the unselected element to the back. Flipping through destinations on the nav bar thus feels a bit like browsing through a carousel. We decided to utilize this effect as it adds a playful note to switching sections, which we hoped would nudge our users into navigating to different areas in the app more often. Further, the animation plays a major part in our next point…

USAGE

compile the library in your build.gralde

allprojects {

repositories {

jcenter()

maven { url "https://jitpack.io" }

}

}

dependencies {

compile 'com.github.githubwing:ByeBurger:1.2.3'

compile 'com.android.support:design:25.0.0'

}

You only need to change the root view to CoordinatorLayout,

And add one line code "app:layout_behavior" like the bottom

into ANY view, Then your view hiding on scroll.

Your titleBar can be Toolbar,LinearLayout and so on.

Your NavigationView can be BottomNavigationView or TabLayout,

or Any View you put in xml.

app:layout_behavior="@string/bye_burger_title_behavior"

/>

android:layout_gravity="bottom"

app:layout_behavior="@string/bye_burger_bottom_behavior"

/>

app:layout_behavior="@string/bye_burger_float_behavior"

/>

You can control it by call method show() hide()

ByeBurgerBehavior.from(mToolbar).hide()

ByeBurgerBehavior.from(mFloatButton).show()

License

Copyright 2016 androidwing1992

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
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的汉堡菜单代码示例: HTML代码: ``` <nav> <div class="hamburger-menu"> <div class="bar"></div> <div class="bar"></div> <div class="bar"></div> </div> <ul> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Services</a></li> <li><a href="#">Contact</a></li> </ul> </nav> ``` CSS代码: ``` nav ul { display: flex; justify-content: space-between; align-items: center; list-style:none; margin:0; padding:0; } nav ul li { margin:0 10px; } nav .hamburger-menu { display: none; } @media screen and (max-width: 768px) { nav ul { display: flex; flex-direction: column; justify-content: flex-start; align-items: flex-start; position: absolute; top: 60px; left: 0; width: 100%; background-color: #333; padding: 20px; transition: transform 0.3s ease-in-out; transform: translateY(-100%); } nav ul.open { transform: translateY(0%); } nav ul li { margin: 10px 0; } nav .hamburger-menu { display: block; cursor: pointer; } nav .bar { height: 3px; width: 25px; background-color: #fff; margin: 5px 0; transition: transform 0.3s ease-in-out; } nav .hamburger-menu.open .bar:nth-child(1) { transform: translateY(8px) rotate(45deg); } nav .hamburger-menu.open .bar:nth-child(2) { opacity: 0; } nav .hamburger-menu.open .bar:nth-child(3) { transform: translateY(-8px) rotate(-45deg); } } ``` JavaScript代码: ``` const hamburgerMenu = document.querySelector('.hamburger-menu'); const navList = document.querySelector('nav ul'); hamburgerMenu.addEventListener('click', () => { hamburgerMenu.classList.toggle('open'); navList.classList.toggle('open'); }); ``` 这个代码示例创建了一个响应式汉堡菜单,当屏幕小于768像素时,菜单将变成一个汉堡按钮,点击按钮将展开一个下拉菜单
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值