Skip to content

MirShu/ScrollView-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

ScrollView-

ScrollView 嵌套 RecyclerView 显示不全

ScrollView嵌套多个元素子view

<ScrollView
        android:id="@+id/my_scrollview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/view_line"
        android:scrollbarSize="3dp"
        android:scrollbarThumbVertical="@drawable/shape_content_scrollbars_style"
        android:layout_marginBottom="50dp"
        android:overScrollMode="never">
  <LinearLayout
        android:id="@+id/ll_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:visibility="gone">
  <X5WebView
        android:id="@+id/news_content"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_marginTop="@dimen/dp10"
        android:layout_marginBottom="@dimen/dp5" />
    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycerView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="@dimen/dp5"
        android:layout_marginRight="10dp" />

 <TextView
        android:id="@+id/tv_created_at"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:paddingLeft="10dp"
        android:text="时间"
        android:textColor="@color/color_676767"
        android:textSize="@dimen/sp12"
        android:visibility="gone" />
 </LinearLayout>
 </ScrollView>

导致 RecyclerView item显示不全,十条数据只显示八条,滑动也有一点点粘连的感觉不是太流畅。 两张图片对比

2781551-7cf3a3efda0f0b62

解决

1、使用NestedScrollView替代ScrollView,解决显示不全

<android.support.v4.widget.NestedScrollView

....

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

能显示全部item 没问题

2781551-abab3878640eeebf

2、滑动粘连不太流畅,ScrollView和RecyclerView都有滑动事件,二者起了冲突,禁止掉RecyclerView滑动事件。 代码里面添加一句

Recycer.setNestedScrollingEnabled(false);

2781551-3ff5a8a1c67b7a3c

About

ScrollView 嵌套 RecyclerView 显示不全

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors