效果图:
[图片上传中...(image.png-fa2111-1565612161926-0)]
项目的gradle
project的build.gradle:
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
module的build.gradle
compile 'com.github.githubwing:ByeBurger:1.2.3'
//Demo中用到了RecyclerView 和Design中的ui
compile 'com.android.support:recyclerview-v7:29.0.1'
compile 'com.android.support:design:29.0.1'
使用CoordinatorLayout作为根布局,然后向你的任何View中插入一句app:layout_behavior属性,即可实现滑动的隐藏和显示
XML:
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/activity_main"
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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ui.wan.fragment.WanFragment">
<com.jiyun.wanandroids.util.NoScrollViewPager
android:id="@+id/wan_vp"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/wan_bnv"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_gravity="bottom"
android:background="#FFFFFF"
app:layout_behavior="@string/bye_burger_bottom_behavior"
android:layout_alignParentBottom="true"
app:itemBackground="@android:color/white"
app:itemIconTint="@drawable/select_textcolor"
app:itemTextColor="@drawable/select_textcolor"
app:labelVisibilityMode="labeled"
app:menu="@menu/wan_menu"/>
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#2196F3"
app:layout_behavior="@string/bye_burger_title_behavior"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/wan_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginBottom="80dp"
android:layout_marginRight="20dp"
android:padding="5dp"
android:src="@android:drawable/ic_dialog_email"
app:layout_behavior="@string/bye_burger_float_behavior"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
网友评论