I\'m trying to use a ViewPager
inside of a ScrollView
, but the ViewPager
does not appear. If I remove the ScrollView
the
In case someone is having the same problem, when I use the class below it works fine.
class CustomWrapContentViewPager(cont: Context, attr: AttributeSet?) : ViewPager(cont,attr) {
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
var height = 0
for (i in 0 until childCount) {
val child: View = getChildAt(i)
child.measure(
widthMeasureSpec,
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)
)
val h: Int = child.measuredHeight
if (h > height) height = h
}
val heightMeasure = MeasureSpec.makeMeasureSpec(
height,
MeasureSpec.EXACTLY
)
super.onMeasure(widthMeasureSpec, heightMeasure)
}
}