This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void initViewPagerAndTabs() { | |
ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); | |
PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager()); | |
pagerAdapter.addFragment(PartThreeFragment.createInstance(20), getString(R.string.tab_1)); | |
pagerAdapter.addFragment(PartThreeFragment.createInstance(4), getString(R.string.tab_2)); | |
viewPager.setAdapter(pagerAdapter); | |
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout); | |
tabLayout.setupWithViewPager(viewPager); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<android.support.v4.view.ViewPager | |
android:id="@+id/viewPager" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
app:layout_behavior="@string/appbar_scrolling_view_behavior"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.design.widget.CoordinatorLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:id="@+id/coordinatorLayout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<android.support.design.widget.AppBarLayout | |
android:id="@+id/appBarLayout" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.v7.widget.RecyclerView | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/recyclerView" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android { | |
compileSdkVersion 22 | |
buildToolsVersion "22.0.1" | |
defaultConfig { | |
minSdkVersion 14 | |
targetSdkVersion 22 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class HidingScrollListener extends RecyclerView.OnScrollListener { | |
private static final float HIDE_THRESHOLD = 10; | |
private static final float SHOW_THRESHOLD = 70; | |
private int mToolbarOffset = 0; | |
private boolean mControlsVisible = true; | |
private int mToolbarHeight; | |
private int mTotalScrolledDistance; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void initRecyclerView() { | |
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView); | |
int paddingTop = Utils.getToolbarHeight(PartTwoActivity.this) + Utils.getTabsHeight(PartTwoActivity.this); | |
recyclerView.setPadding(recyclerView.getPaddingLeft(), paddingTop, recyclerView.getPaddingRight(), recyclerView.getPaddingBottom()); | |
recyclerView.setLayoutManager(new LinearLayoutManager(this)); | |
// ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="@dimen/tabsHeight" | |
android:background="?attr/colorPrimary"> | |
<FrameLayout | |
android:layout_width="0dp" | |
android:layout_height="match_parent" | |
android:layout_weight="1" > | |
<TextView | |
android:layout_width="match_parent" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<android.support.v7.widget.RecyclerView | |
android:id="@+id/recyclerView" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:clipToPadding="false"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void initRecyclerView() { | |
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView); | |
recyclerView.setLayoutManager(new LinearLayoutManager(this)); | |
RecyclerAdapter recyclerAdapter = new RecyclerAdapter(createItemList()); | |
recyclerView.setAdapter(recyclerAdapter); | |
recyclerView.setOnScrollListener(new HidingScrollListener(this) { | |
@Override | |
public void onMoved(int distance) { |