Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
youlookwhat committed Sep 27, 2020
1 parent 5c9de7f commit 7baf716
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sbanner/src/main/java/me/jingbin/sbanner/SBannerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public SBannerView setPageRightMargin(int pageRightMargin) {
}

/**
* @param pageLeftMargin banner距屏幕的右边距
* @param pageLeftMargin banner距屏幕的左边距
*/
public SBannerView setPageLeftMargin(int pageLeftMargin) {
this.mPageLeftMargin = pageLeftMargin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import android.util.AttributeSet;
import android.view.MotionEvent;

import java.lang.reflect.Field;

public class BannerViewPager extends ViewPager {

private boolean scrollable = true;
Expand All @@ -31,4 +33,19 @@ public void setScrollable(boolean scrollable) {
this.scrollable = scrollable;
}

@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
/**
* 解决完全隐藏ViewPager,再回来时,第一次滑动时没有动画效果,并且,经常出现view没有加载的情况的bug
*/
try {
Field mFirstLayout = ViewPager.class.getDeclaredField("mFirstLayout");
mFirstLayout.setAccessible(true);
mFirstLayout.set(this, false);
setCurrentItem(getCurrentItem());
} catch (Exception e) {
e.printStackTrace();
}
}
}

0 comments on commit 7baf716

Please sign in to comment.