Dynamic height viewpager

后端 未结 6 1348
無奈伤痛
無奈伤痛 2020-11-27 13:06

I\'m trying to create a custom viewpager inside custom scroll viewthat dynamically wraps the current child\'s height.

package com.example.vihaan.dynamicviewp         


        
6条回答
  •  再見小時候
    2020-11-27 13:38

    Adding to @vihaan's solution, if you have a PagerTitleStrip or PagetTabStrip, you can add this

    // Account for pagerTitleStrip or pagerTabStrip
    View tabStrip = getChildAt(0);
    if (tabStrip instanceof PagerTitleStrip) {
        tabStrip.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.UNSPECIFIED));
        height += tabStrip.getMeasuredHeight();
    }
    

    just before starting the animation (before the comment

     // Not the best place to put this animation, but it works pretty good.
    

    so that the height of the strip is taken into account.

提交回复
热议问题