Displaying Results in RecyclerView
For your last task in this chapter, you will switch to the view layer and get PhotoGalleryFragment’s RecyclerView to display some images.
Start by creating a layout for an individual list item. In the project tool window, right-click the res/layout directory and choose New → Layout Resource File. Name the file list_item_gallery, set the root element to ImageView, and click OK.
Within the layout, update and add a few XML attributes.
The RecyclerView will provide the list item with an appropriate width, so keep the android:layout_width
set to match_parent
.
But limit the height to 120dp
.
That will allow the user to see multiple rows of images within your RecyclerView onscreen at once.
Flickr does ...
Get Android Programming: The Big Nerd Ranch Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.