use of com.fivehundredpx.greedolayout.GreedoSpacingItemDecoration in project greedo-layout-for-android by 500px.
the class SampleActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
PhotosAdapter photosAdapter = new PhotosAdapter(this);
final GreedoLayoutManager layoutManager = new GreedoLayoutManager(photosAdapter);
layoutManager.setMaxRowHeight(MeasUtils.dpToPx(150, this));
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(photosAdapter);
int spacing = MeasUtils.dpToPx(4, this);
recyclerView.addItemDecoration(new GreedoSpacingItemDecoration(spacing));
findViewById(R.id.toggle_fixed_height).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
layoutManager.setFixedHeight(((ToggleButton) view).isChecked());
layoutManager.requestLayout();
}
});
}
Aggregations