ScrollView嵌套RecyclerView出現(xiàn)item顯示不全的問題

第一種:在你的RecyclerView上外邊嵌套一層RelativeLayout,

然后添加屬性?android:descendantFocusability="blocksDescendants",

如:

<RelativeLayout

? ? android:layout_width="match_parent"

? ? android:layout_height="wrap_content"

? ? android:descendantFocusability="blocksDescendants">

? ? <android.support.v7.widget.RecyclerView

? ? ? ? android:id="@+id/rv_meeting"

? ? ? ? android:paddingLeft="15dp"

? ? ? ? android:paddingRight="15dp"

? ? ? ? android:layout_width="match_parent"

? ? ? ? android:layout_height="wrap_content"/>

</RelativeLayout>

PS:既然提到了這個屬性就說下它的意思吧,知道的同學再復習一遍唄,鞏固鞏固更牢靠。

屬性android:descendantFocusability的含義是:當一個view獲取焦點時,定義ViewGroup和其子控件兩者之間的關(guān)系。

它一共有3個屬性值,它們分別是:

beforeDescendants:viewGroup會優(yōu)先子類控件而獲取焦點

afterDescendants:viewGroup只有當子類控件不需要獲取焦點的時候才去獲取焦點

blocksDescendants:viewGroup會覆蓋子類控件而直接獲取焦點

第二種方法:

首先在xml布局中將你的ScrollView替換成android.support.v4.widget.NestedScrollView,

并在java代碼中設(shè)置recyclerView.setNestedScrollingEnabled(false);

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

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

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