Chapter 7 - match_parent option not available in latest Android Studio

In Android Studio v3.1.3 (latest version) the match_parent option is no longer available the layout_width and layout_height in RecyclerView Attributes.

Hi lincbarr,

Thanks for letting us know about the problems you’ve found following along with the book.

We want Android Apprentice to be the best Android book on the market, your feedback helps towards that goal and we’ll make sure it gets put to good use.

Keep in touch and let us know what you think of the book.

Thanks,

Darryl

So what is the solution here then @daemonic_daz? Leave it at the hard-coded height and width?

Hey mwbeatty,

The solution is to set constraints on the RecyclerView that reach out to the edges of the layout in content_main.xml. You can do this in the RecyclerView attributes when using the design tab for the layout.

Also in the attributes view, make sure the margins for each constraint are set to 0 to avoid any unneeded padding, then make sure the layout_width and layout_height attributes for the RecyclerView are set to match_constraint. This forces the width and height of the RecyclerView to adhere to the constraints

Your design view should look something like this:

34

The xml for the RecyclerView looks like:

    <android.support.v7.widget.RecyclerView
      android:id="@+id/lists_recyclerview"
      android:layout_width="0dp"
      android:layout_height="0dp"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent" />

Hope this helps.

Darryl