Android导航栏滑动折叠效果

本项目提供了一个基于NestedScrollingParent实现的导航栏滑动折叠效果的ViewGroup组件,可在Android项目中轻松集成。通过在XML布局文件中声明特定ID的View,如fold_nav_layout、fold_tab_layout和fold_content_layout,即可实现导航栏随滚动方向显示或隐藏的效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

项目地址

https://github.com/oneAcorn/FoldNavScrollLayout
-------------------------------------------------------------------我是分割线---------------------------------------------------------------------

使用NestedScrollingParent实现的导航栏滑动折叠效果的ViewGroup

在这里插入图片描述

一 引用方法

1.在root build.gradle中加入
allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
2.在项目的 build.gradle中加入
dependencies {
	        implementation 'com.github.oneAcorn:FoldNavScrollLayout:1.0'
	}

二 使用方法

1.在xml中声明(FoldNavScrollLayout内的View只是示例,只要id是对的就行)
<?xml version="1.0" encoding="utf-8"?>
<com.acorn.library.FoldNavScrollLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <RelativeLayout
        android:id="@id/fold_nav_layout"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:background="#ffffff"/>

    <android.support.design.widget.TabLayout
        android:id="@id/fold_tab_layout"
        android:layout_width="match_parent"
        android:layout_height="34dp"
        />

    <android.support.v4.view.ViewPager
        android:id="@id/fold_content_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />
</com.acorn.library.FoldNavScrollLayout>

请注意,FoldNavScrollLayout内第一层childView需要至少有3个如下id的View存在

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item name="fold_nav_layout" type="id"/>
    <item name="fold_tab_layout" type="id"/>
    <item name="fold_content_layout" type="id"/>
</resources>

作用分别是
fold_nav_layout 导航栏,拖动时根据方向显示/隐藏
fold_tab_layout 位置固定的View,不一定是TabLayout
fold_content_layout 可竖向滑动的View

2.完成,就当它是个LinearLayout,该怎么用就怎么用

项目地址

https://github.com/oneAcorn/FoldNavScrollLayout

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值