Seamless nested scrolling (Android)

前端 未结 8 1418
不知归路
不知归路 2020-12-15 01:46

We\'ve all been advised against nesting views that contain a scrolling mechanism. However, in the latest Android release (5.0), the Phone app caught my attention with what s

相关标签:
8条回答
  • 2020-12-15 02:21

    I have been wanting to achieve the same effect as well. I came up finding a relevant library called ObservableScrollView in GitHub and it requires more work on the back-end via a TouchInterceptFramework but at least it did the job even for pre-lollipop devices. It also supports not only child scrollviews and listviews but also recyclerviews. Here's the link:

    https://github.com/ksoichiro/Android-ObservableScrollView

    I hope they consider nested scrolling for both lollipop and pre-lollipop devices as a part of their design standard soon. This is a good sign.

    0 讨论(0)
  • 2020-12-15 02:21

    You can use the following combination of attributes on your ListView to achieve this:

    <ImageView ... /> <!-- must be before ListView -->
    
    <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingTop="..." <!-- height of imageView -->
        android:clipToPadding="false"
        ...
    />
    

    You don't have to manage any scrolling in your code at all, and it requires no header/dummy views in your list adapter.

    0 讨论(0)
提交回复
热议问题