我有嵌套的滚动视图,里面有一个回收站视图。但是当我开始滚动时,嵌套的滚动视图会滚动所有内容。我必须将滚动视图与滚动视图分开滚动。
<RelativeLayout
<NestedScrollview
<LinearLayout
<ImageView/>
</LinearLayout>
<Recyclerview/>
<NestedScrollview/>
</RelativeLayout>
答案 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
}
}