约束布局ConstraintLayout嵌入RecycleView类似的导致item显示不全解决方案




    
    

    
    



ViewPager中的Fragment,放的就是图中的那个RecyclerView(RecyclerView的最后一个条目显示不全)。ViewPager的高度设为0dp,app:layout_constraintVertical_weight为1,其实就和LinearLayout中的weight是一样的。 app:layout_constraintTop_toBottomOf="@id/tab_layout"表示ViewPager在TabLayout的下面。

RecyclerView最后一个条目为什么会显示不全?这是因为在ConstraintLayout中,如果height设置为0,就一定要给控件设置上约束和下约束。这里的ViewPager只设置了上约束在tablayout的下面,而没有设置下约束。只要加上app:layout_constraintBottom_toBottomOf=“parent”,给ViewPager设置一个下约束在parent的上面,问题就解决了

关键点:android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/tab_layout"
app:layout_constraintBottom_toBottomOf="parent"

你可能感兴趣的:(约束布局ConstraintLayout嵌入RecycleView类似的导致item显示不全解决方案)