ogaclejapan / SmartTabLayout

A custom ViewPager title strip which gives continuous feedback to the user when scrolling
Apache License 2.0
7.09k stars 1.34k forks source link

onScrollChanged doesnt work #137

Closed jjhesk closed 8 years ago

jjhesk commented 8 years ago

   @SuppressLint("ResourceAsColor")
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
    @Override
    public void onViewCreated(View v, Bundle b) {
        mTab = (SmartTabLayout) v.findViewById(R.id.feature_puzzle_smarttab);
        pager = (ViewPager) v.findViewById(R.id.feature_puzzle_viewpager);
        pager.setAdapter(getAdapter());
        pager.setOffscreenPageLimit(0);
        mTab.setViewPager(pager);
        mTab.setOnScrollChangeListener(this);
        toolBarHeight = Utils.getToolbarHeight(getActivity());
        customBarHeight = Utils.getTabsHeight(getActivity());
    }

   @Override
    public void onScrollChanged(int scrollX, int oldScrollX) {
        Log.d("smtab", scrollX + " int");
    }

it doesnt seem to work.. the machine is api V21, android 5.1.1

ogaclejapan commented 8 years ago

Hi, @jjhesk I'm sorry late reply. I’ve been busy lately at work :P

Do you already resolved? I tried on a DEMO app but is running correctly.

https://github.com/ogaclejapan/SmartTabLayout/blob/master/demo/src/main/java/com/ogaclejapan/smarttablayout/demo/DemoActivity.java#L57

    viewPagerTab.setOnScrollChangeListener(new SmartTabLayout.OnScrollChangeListener() {
      @Override
      public void onScrollChanged(int scrollX, int oldScrollX) {
        Log.w("TRACE", String.format("scrollX=%d, oldScrollX=%d", scrollX, oldScrollX));
      }
    });