CoordinatorLayoutt +SwipeRefresh实现刷新加载多标签的咨询页

本文介绍了如何在Android项目中利用CoordinatorLayout和AppBarLayout结合SwipeRefresh实现一个带有轮播图、刷新加载功能的多标签新闻资讯页面。在解决滑动手势冲突的同时,详细阐述了监听AppBarLayout偏移量和RecyclerView滚动状态的方法,以确保正确触发下拉刷新和上拉加载更多。最后,针对加载更多时出现的问题进行了分析和解决,确保每个标签页正常工作。

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

最近项目中需要实现一个新闻资讯页,但是要求标签上面有轮播图,而且要支持刷新和加载,标签页要滑动到顶部固定

想必大家对Coordinayout 和AppbarLayout都比较熟悉了,这里我就不介绍了


我们这里要解决的问题是滑动刷新和加载的手势冲突

这里先上效果图


布局如下,分四个模块,

SwipeRefresh

Coordinayout

AppBarLayout

Indicator


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout   xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:layout_width="match_parent" >
    <android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:title="咨询"
    app:titleTextColor="@color/white"
    android:background="@color/color_gold_text"
    android:layout_width="match_parent"
    android:layout_height="@dimen/action_bar_size"/>
<com.coordinayout.tgy.myapplication.view.SwipeLayout
    android:id="@+id/swipe_layout"
    android:layout_width="match_parent"
    app:load_more_enabled="false"
    android:layout_height="match_parent">
    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/swipe_target"
        android:layout_w
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值