移动开发第二次作业——实现顶部悬浮的滑动列表

顶部悬浮的滑动列表

一、本项目完成的功能
在上次作业类微信app中的一个可切换页面中实现下述功能:
1.用列表显示若干个英语音乐剧和法语音乐剧,以及它们的剧目名称
2.实现顶部悬浮功能,即向上滑动展示下面的内容时,分组名可以在顶部悬浮,直到该分组内容向上滑动退出屏幕页面,分组名跟随分组内容退出屏幕页面

二、布局文件
在第一次实验的基础上需要修改一个xml文件,增加两个xml文件
1.在上次作业中的tab02.xml文件中,删除TextView,拖入RecyclerView,此时系统会自动导入RecyclerView相关的依赖包

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rcv_sticky"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:overScrollMode="never"
        android:scrollbars="none" />

    <include layout="@layout/sticky_include_recycle_item" />

</RelativeLayout>

2.新建两个item.xml文件,内容为TextView,用来显示分组名和分组内容

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/tv_sticky_header_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/colorAccent"
    android:padding="20dp"
    android:textColor="@android:color/white"
    android:textSize="30sp"
    tools:text="@string/app_name" />
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <include layout="@layout/sticky_include_recycle_item" />

    <TextView
        android:id="@+id/tv_novel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="17dp"
        
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值