Skip to content

Instantly share code, notes, and snippets.

@Suleiman19
Last active April 1, 2017 06:47
Show Gist options
  • Save Suleiman19/8f1215a6ebffa77dc51257e881b1aa10 to your computer and use it in GitHub Desktop.
Save Suleiman19/8f1215a6ebffa77dc51257e881b1aa10 to your computer and use it in GitHub Desktop.
Dummy Fragment that contains a scrollable list to demonstrate parallax scroll effect.
public static class DummyFragment extends Fragment {
int color;
public DummyFragment() {
}
@SuppressLint("ValidFragment")
public DummyFragment(int color) {
this.color = color;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.dummy_fragment, container, false);
final FrameLayout frameLayout = (FrameLayout) view.findViewById(R.id.dummyfrag_bg);
frameLayout.setBackgroundColor(color);
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.dummyfrag_scrollableview);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity().getBaseContext());
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setHasFixedSize(true);
DessertAdapter adapter = new DessertAdapter(getContext());
recyclerView.setAdapter(adapter);
return view;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment