【Android 仿钉钉上下滑动tabbar的实现】

之前一段时间,项目里有让模仿钉钉的tabbar上下滑动实现次级菜单的效果。本着面向baidu的编程思维搜索了一圈,貌似没有找到,只找到一个IOS上的实现,先看一下最终要的效果是怎么样的吧。
在这里插入图片描述
图是别人的图,就是实现这个效果。然后想到了CoordinatorLayout 里面有方便实现这样的效果,开始撸代码。

先来布局xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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">

    <androidx.viewpager.widget.ViewPager
        android:id="@+id/vp_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="56dp" />

    <androidx.core.widget.NestedScrollView
        android:id="@+id/scroll"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/white"
        app:behavior_hideable="false"
        app:behavior_peekHeight="60dp"
        app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <LinearLayout
                android:id="@+id/llRoot"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <RadioGroup
                    android:id="@+id/rg_main_bottom"
                    android:layout_width="match_parent"
                    android:layout_height="56dp"
                    android:orientation="horizontal">

                    <RadioButton
                        android:id="@+id/rb1"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_marginTop="6dp"
                        android:layout_weight="1"
                        android:checked="true"
                        android:gravity="center"
                        android:text="button1&
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值