嵌套scrollview中的回收站视图滚动问题

时间:2018-12-24 07:47:33

标签: android android-recyclerview android-nestedscrollview

我有嵌套的滚动视图,里面有一个回收站视图。但是当我开始滚动时,嵌套的滚动视图会滚动所有内容。我必须将滚动视图与滚动视图分开滚动。

<RelativeLayout

  <NestedScrollview 

      <LinearLayout

           <ImageView/>

      </LinearLayout>  

 <Recyclerview/>

   <NestedScrollview/>

</RelativeLayout>

1 个答案:

答案 0 :(得分:0)

使用下面的Recyclerview

class NonScrollRecyclerView(context: Context, attributeSet: AttributeSet) : RecyclerView(context, attributeSet) {

override fun onMeasure(widthSpec: Int, heightSpec: Int) {
        val heightMeasureSpecCustom = MeasureSpec.makeMeasureSpec(
        Integer.MAX_VALUE shr 2, MeasureSpec.AT_MOST
    )
    super.onMeasure(widthSpec, heightMeasureSpecCustom)
    val params = layoutParams
    params.height = measuredHeight
}

}