【问题标题】:Android scroll listView like Viber像 Viber 一样的 Android 滚动 listView
【发布时间】:2016-10-13 19:28:04
【问题描述】:

我只是想知道如何将这个效果添加到我的 listView 或 RecyclerView 以进行滚动,而没有一个项目更像 viber 聊天。

查看照片以了解我的意思。 在滚动此聊天结束之前:

现在滚动,聊天结束,情绪像春天:

【问题讨论】:

    标签: android listview


    【解决方案1】:

    这是我之前写的一个类 https://github.com/omiz/ZSwipeRefreshLayout/blob/master/ZSwipeRefreshLayout

    要使用它,您只需像这样在其中添加您的列表

    <ZSwipeRefreshLayout
                android:id="@+id/swipe_refresh"
                android:layout_width="match_parent"
                android:layout_height="match_parent">
    
                <android.support.v7.widget.RecyclerView
                    android:id="@+id/main_recyclerView_days"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"/>
    </ZSwipeRefreshLayout>
    

    在你的代码中

    swipeRefreshLayout = (ZSwipeRefreshLayout) findViewById(R.id.swipe_refresh);
    
    swipeRefreshLayout.setHeaderView(createHeaderView());
    
    swipeRefreshLayout.setPushEnable(true);
    
    swipeRefreshLayout.setPullEnable(true);
    
    swipeRefreshLayout.setOnPullRefreshListener(this);
    

    顺便说一句,这个答案是让 ListView 或 RecyclerView 像 iOS 效果一样弹跳

    【讨论】:

    • 如果您需要任何进一步的帮助,请告诉我
    • 为 GrideView 工作,createHeaderView() 显示错误我现在在片段上
    • 我只在ListView和RecyclerView中测试过
    • createHeaderView() 是您选择的任何视图,您可以添加一个空视图
    猜你喜欢
    • 1970-01-01
    • 2011-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-24
    • 2011-01-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多