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

Low FPS with RecyclerView #24

Closed ppamorim closed 9 years ago

ppamorim commented 9 years ago

Hi! I'm facing some laggy animation on ViewPager transition. Everything on app is fast (animations, recyclerView), but when I start the transition with the library, the fps slow down until the animation ends. I've test only with a ViewPager and the slide of it is faster than wind. It a prove that is a problem with the library(or animation of smartTab).

<com.ogaclejapan.smarttablayout.SmartTabLayout
                android:id="@+id/smart_tab_layout"
                android:layout_width="match_parent"
                android:layout_height="48dp"
                android:paddingBottom="4dp"
                android:background="@color/actionbar_color"
                app:stl_indicatorAlwaysInCenter="false"
                app:stl_indicatorInFront="false"
                app:stl_indicatorInterpolation="smart"
                app:stl_indicatorColor="@color/razzmatazz"
                app:stl_indicatorThickness="4dp"
                app:stl_indicatorCornerRadius="2dp"
                app:stl_underlineThickness="0dp"
                app:stl_dividerThickness="0dp"
                app:stl_defaultTabBackground="?attr/selectableItemBackground"
                app:stl_defaultTabTextAllCaps="false"
                app:stl_defaultTabTextColor="@color/mine_shaft"
                app:stl_defaultTabTextSize="12sp"
                app:stl_defaultTabTextHorizontalPadding="12dp"
                app:stl_defaultTabTextMinWidth="0dp"
                app:stl_distributeEvenly="true"/>

Device: S4 mini

ppamorim commented 9 years ago

Well, I've found the solution for this issue.

Just add this:

private ViewPager.OnPageChangeListener onPageChangeListener =
  new ViewPager.OnPageChangeListener() {
@Override public void onPageScrolled(int position, float positionOffset,
    int positionOffsetPixels) {

  if(positionOffsetPixels != 0) {
    return;
  }

  Fragment page = adapter.getPage(position);
  ... rest of the code...
}
@Override public void onPageSelected(int position) { }
@Override public void onPageScrollStateChanged(int state) { }
};

Can you add this on your example?

AlexandruDev commented 8 years ago

@ppamorim

Hello, can you show me your solution a bit more detailed? In my app, when I swipe fast the tabs there's a glitch and I just can't find a way to fix it.

Thank you!