Android pinch-to-zoom layout inside a viewpager with padding left and right

前端 未结 2 884
醉酒成梦
醉酒成梦 2021-01-15 08:46

I have a viewpager with left and right padding for showing the previews of left and right pages of viewpager.

viewPager.setPadding(30,0,30,0);
相关标签:
2条回答
  • 2021-01-15 09:25

    Did you try putting zoomview beside viewpager in framelayout (not in each page) so it is on top of viewpager.

    0 讨论(0)
  • 2021-01-15 09:29

    Try this, it's worked for me using this :https://gist.github.com/atermenji/3781644

    public class ImageZoomViewPager extends ViewPager {
    
    public ImageZoomViewPager(Context context) {
        super(context);
    }
    
    public ImageZoomViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    
    @Override
    protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
        if (v instanceof ImageViewTouch) {
            return ((ImageViewTouch) v).canScroll(dx);
        } else {
            return super.canScroll(v, checkV, dx, x, y);
        }
    }}
    
    0 讨论(0)
提交回复
热议问题