ScrollView 嵌套 RecyclerView 顯示不全

ScrollView嵌套多個(gè)元素子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="時(shí)間"
        android:textColor="@color/color_676767"
        android:textSize="@dimen/sp12"
        android:visibility="gone" />
 </LinearLayout>
 </ScrollView>

導(dǎo)致 RecyclerView item顯示不全,十條數(shù)據(jù)只顯示八條,滑動(dòng)也有一點(diǎn)點(diǎn)粘連的感覺不是太流暢。
兩張圖片對(duì)比


解決

1、

使用NestedScrollView替代ScrollView,解決顯示不全

 <android.support.v4.widget.NestedScrollView

....

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

能顯示全部item 沒問題


2、

滑動(dòng)粘連不太流暢,ScrollView和RecyclerView都有滑動(dòng)事件,二者起了沖突,禁止掉RecyclerView滑動(dòng)事件。 代碼里面添加一句

Recycer.setNestedScrollingEnabled(false);
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容