Android小白_努力中Android开发Android知识

实现Coordinatorlayout与tableLayout复

2017-06-23  本文已影响270人  秦子帅

效果图:


源码(github)地址

我的博客地址

我的公众号:


思路:

1.首先解决Coordinatorlayout与tableLayout复合效果.

2.RecycleView上拉加载,以及RecycleView的item点击事件.

3.点击条目跳转的URL,添加一个状态View:MultiStateView.

1.(1)

dependencies {
    compile 'cn.hugeterry.coordinatortablayout:coordinatortablayout:1.0.6'
}

(2)

<cn.hugeterry.coordinatortablayout.CoordinatorTabLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/coordinatortablayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.view.ViewPager
        android:id="@+id/vp"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</cn.hugeterry.coordinatortablayout.CoordinatorTabLayout>

(3)

1.setTitle(String title):Set the CoordinatorTabLayout's title.

2.setupWithViewPager(ViewPager viewPager):To link the two together.

3.setImageArray(int[] imageArray):Set the image array of the header according to the number of tabs and pass it to the control.

CoordinatorTabLayout的github地址

2.

RecycleView想必到家都会的,当时由于时间的原因我用的是AnimRefreshRecyclerView,我在用AnimRefreshRecyclerView的时候我发现了它的不足之处, 上拉加载没有问题,但是在下拉刷新时,如果对RecycleView的item设置完点击事件后,无法下拉刷新,换句话说只要item中大部分控件都有了点击事件,那么久无法下拉刷新, 所以大家在用这个库的时候要慎重。

3.根据加载状态切换不同的界面

四种不同的状态:

Content

Empty

Error

Loading

这个比较简单:直接用的是MultiStateView,实测这个库比较好用.

MultiStateView库地址

上一篇 下一篇

猜你喜欢

热点阅读