use of com.github.ksoichiro.android.observablescrollview.TouchInterceptionFrameLayout in project Android-ObservableScrollView by ksoichiro.
the class FlexibleSpaceWithImageWithViewPagerTab2Activity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_flexiblespacewithimagewithviewpagertab2);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
ViewCompat.setElevation(findViewById(R.id.header), getResources().getDimension(R.dimen.toolbar_elevation));
mPagerAdapter = new NavigationAdapter(getSupportFragmentManager());
mPager = (ViewPager) findViewById(R.id.pager);
mPager.setAdapter(mPagerAdapter);
mImageView = findViewById(R.id.image);
mOverlayView = findViewById(R.id.overlay);
// Padding for ViewPager must be set outside the ViewPager itself
// because with padding, EdgeEffect of ViewPager become strange.
mFlexibleSpaceHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
mTabHeight = getResources().getDimensionPixelSize(R.dimen.tab_height);
findViewById(R.id.pager_wrapper).setPadding(0, mFlexibleSpaceHeight, 0, 0);
mTitleView = (TextView) findViewById(R.id.title);
mTitleView.setText(getTitle());
setTitle(null);
SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
slidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1);
slidingTabLayout.setSelectedIndicatorColors(getResources().getColor(R.color.accent));
slidingTabLayout.setDistributeEvenly(true);
slidingTabLayout.setViewPager(mPager);
((FrameLayout.LayoutParams) slidingTabLayout.getLayoutParams()).topMargin = mFlexibleSpaceHeight - mTabHeight;
ViewConfiguration vc = ViewConfiguration.get(this);
mSlop = vc.getScaledTouchSlop();
mMaximumVelocity = vc.getScaledMaximumFlingVelocity();
mInterceptionLayout = (TouchInterceptionFrameLayout) findViewById(R.id.container);
mInterceptionLayout.setScrollInterceptionListener(mInterceptionListener);
mScroller = new OverScroller(getApplicationContext());
ScrollUtils.addOnGlobalLayoutListener(mInterceptionLayout, new Runnable() {
@Override
public void run() {
// Extra space is required to move mInterceptionLayout when it's scrolled.
// It's better to adjust its height when it's laid out
// than to adjust the height when scroll events (onMoveMotionEvent) occur
// because it causes lagging.
// See #87: https://github.com/ksoichiro/Android-ObservableScrollView/issues/87
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInterceptionLayout.getLayoutParams();
lp.height = getScreenHeight() + mFlexibleSpaceHeight;
mInterceptionLayout.requestLayout();
updateFlexibleSpace();
}
});
}
Aggregations