当前位置: 主页 > 开源代码 >

ScrollDownLayout ScrollView和viewpager同事存在的事件处理

分享

介绍:

ScrollDownLayout ScrollView和viewpager同事存在的事件处理,并且很好的处理事件问题,
本项目通过自定义ScrollDownLayout和ContentScrollView来处理的,里面嵌入ViewPager。
支持手势下滑退出页面 ,
主要代码如下:
{
 ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
        mGirlDesText = (TextView)findViewById(R.id.text_view);
        mScrollDownLayout = (ScrollDownLayout) findViewById(R.id.scroll_down_layout);

        mScrollDownLayout.setMinOffset(0);
        mScrollDownLayout.setMaxOffset(800);
        mScrollDownLayout.setExitOffset(1674);
        mScrollDownLayout.setToOpen();
        mScrollDownLayout.setIsSupportExit(true);
        mScrollDownLayout.setAllowHorizontalScroll(true);
        mScrollDownLayout.setOnScrollChangedListener(mOnScrollChangedListener);

        MainPagerAdapter mainPagerAdapter = new MainPagerAdapter(this);
        mainPagerAdapter.setOnClickItemListener(mOnClickItemListener);
        viewPager.setAdapter(mainPagerAdapter);
        viewPager.setOnPageChangeListener(mOnPageChangeListener);
        initGirlUrl();
        mainPagerAdapter.initViewUrl(mAllGirlList);
        mGirlDesText.setText(mAllGirlList.get(0).getDesContent());

 }

 private void initGirlUrl() {
        mAllGirlList = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            Girl girl = new Girl();
            girl.setImageUrl(Contstants.ImageUrl[i]);
            girl.setDesContent(Contstants.DesContent[i]);
            mAllGirlList.add(girl);
        }
    }

运行效果: