Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Recycler View - Android Alliance March 2016

Recycler View - Android Alliance March 2016

An intro to RecyclerView

Yash Prabhu

March 30, 2016
Tweet

More Decks by Yash Prabhu

Other Decks in Technology

Transcript

  1. View Item <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android. com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="300dp"

    android:layout_height="300dp" android:layout_margin="@dimen/spacing"> <ImageView android:id="@+id/image" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" tools:src="@mipmap/ic_launcher" /> <TextView android:id="@+id/text" android:layout_width="match_parent" android:layout_height="60dp" android:layout_gravity="bottom" android:textColor="@android:color/white" android:gravity="center" android:background="#80222222" android:padding="@dimen/spacing" tools:text
  2. Show me the code! setContentView(R.layout.recycler_layout); recyclerView = (RecyclerView) findViewById(R.id.my_recycler_view); recyclerView.setHasFixedSize(true);

    adapter = new RecyclerAdapter(items, R.layout.grid_view_item); recyclerView.setAdapter(adapter); layoutManager = new GridLayoutManager(this, spanCount); recyclerView.setLayoutManager(layoutManager); recyclerView.setItemAnimator(new DefaultItemAnimator());