Skip to content

Commit

Permalink
Update sample with vertical list that fits the whole screen
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensousa committed Jul 26, 2017
1 parent def6331 commit 92d10a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Gravity;
import android.view.MenuItem;

Expand Down Expand Up @@ -58,13 +59,17 @@ private void setupAdapter() {
snapAdapter.addSnap(new Snap(Gravity.START, "Snap start", apps));
snapAdapter.addSnap(new Snap(Gravity.END, "Snap end", apps));
snapAdapter.addSnap(new Snap(Gravity.CENTER, "GravityPager snap", apps));
mRecyclerView.setAdapter(snapAdapter);
} else {
snapAdapter.addSnap(new Snap(Gravity.CENTER_VERTICAL, "Snap center", apps));
snapAdapter.addSnap(new Snap(Gravity.TOP, "Snap top", apps));
snapAdapter.addSnap(new Snap(Gravity.BOTTOM, "Snap bottom", apps));
Adapter adapter = new Adapter(false, false, apps);
mRecyclerView.setAdapter(adapter);
new GravitySnapHelper(Gravity.TOP, false, new GravitySnapHelper.SnapListener() {
@Override
public void onSnap(int position) {
Log.d("Snapped", position + "");
}
}).attachToRecyclerView(mRecyclerView);
}

mRecyclerView.setAdapter(snapAdapter);
}

private List<App> getApps() {
Expand Down
12 changes: 3 additions & 9 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.v4.widget.NestedScrollView
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
app:layout_behavior="@string/appbar_scrolling_view_behavior" />


<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</android.support.v4.widget.NestedScrollView>

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down

0 comments on commit 92d10a7

Please sign in to comment.