ListView控件嵌套在滚动API< 21 [英] ListView nested scrolling on API<21

本文介绍了ListView控件嵌套在滚动API< 21的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题是明确的。我在这个布局:

Title is clear. I'm having this layout:

_________________
|_______________| <- Toolbar    
|___|___|___|___| <- Tablayout
|               |
|               |
|   ViewPager   |
|               |
|_______________|

这两个工具栏和tablayout是内部的 AppBarLayout ,这样我就可以使用滚动标志来隐藏向顶部滚动工具栏。问题是,这只是嵌套滚动支持意见的工作。大部分的标签 - 我的意思是,大部分的网页 - 是 support.v4.NestedScrollView S,所以这是确定的;另一些(而且必须)的ListView 秒。

Both toolbar and tablayout are inside an AppBarLayout, so I can use scroll flags to hide the toolbar on scrolling toward the top. The problem is that this only works with nested-scrolling-supported views. Most of the tabs - I mean, most of the pages - are support.v4.NestedScrollViews, so that is OK; others are (and need to be) ListViews.

从棒棒糖,我可以简单地添加的android:nestedScrollingEnabled =真正的列表视图,并在工具栏正确揣上滚动

From Lollipop on, I can simply add android:nestedScrollingEnabled="true" to the list view, and the toolbar hides correctly on scroll.

在API&LT; 21,虽然,有没有这样的属性和工具栏不隐藏。更重要的是,在列表的最后项目被隐藏,因为 CoordinatorLayout 部分测量的bug,:列表视图充当如果它有空间,目前由工具栏占据

On API<21, though, there's no such attribute and the toolbar doesn't hide. Even more important, the very last items in the list are hidden, because of some measuring bug in CoordinatorLayout: listview acts as if it had the space currently occupied by the toolbar.

解决方案:


  • 切换到 RecyclerView ,它不支持嵌套滚动:我不能,因为我需要使用仅带适配器工作意见的外部库适配器而我不能代替(即 ParseQueryAdapter );

  • Switch to RecyclerView, which does support nested scrolling: I can't, because I need to use an external-library adapter that works only with adapter views and that I can't replace (namely, ParseQueryAdapter);

扩展的ListView 和实现嵌套滚动:好像方式复杂;

Extend ListView and implement nested scrolling: seems way to complicated;

延长的ListView 并实施一些解决方法,比如测量的东西,以避免最后一个项目的问题或(和)的自定义行为,使工具栏隐藏:似乎太复杂;

Extend ListView and implement some workaround, like measuring stuff to avoid the last-item issue or (and) a custom behavior to make the toolbar hide: seems complicated too;

使用一些布局窍门:发现无

Use some layout trick: found none.

任何帮助吗?

例如,我(拼命)的尝试:

For example, I (desperately) tried:

<android.support.v4.widget.NestedScrollView
    android:nestedScrollingEnabled="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </ListView>

</android.support.v4.widget.NestedScrollView>

但这种方式的ListView 未布局为 match_parent 。我得到小高一点点看法,以及页面的其余部分是空的。

But this way the ListView is not laid out as match_parent. I get a little view with small height, and the rest of the page is empty.

推荐答案

不幸的是,有没有办法让嵌套的滚动工作的ListView - 否则它不会要求在API 21人做了修改。

Unfortunately, there is no way to get nested scrolling working on ListView - otherwise it wouldn't require the modifications that were done in API 21.

您会注意到,目前解析SDK 实际上已经删除 ParseQueryAdapter 完全。鉴于这种情况,它可能是有意义的开始使用的 RecyclerView 基于适配器相对=nofollow>分析查询的API直接的。

You'll note that the current Parse SDK has actually removed ParseQueryAdapter entirely. Given that, it may make sense to start building your own RecyclerView based adapter using the Parse query APIs directly.

这篇关于ListView控件嵌套在滚动API&LT; 21的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆