My problem is very similar to this question, however unlike it's OP I'm passing the parent to the LayoutInflater. I'm using support library 25.3.1. Here's the layout that I'm inflating (Changing the ConstraintLayout to LinearLayout doesn't help):
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="72dp"
android:background="?android:selectableItemBackground"
android:clickable="true"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="81dp">
<TextView
android:id="@+id/list_text_primary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.ListPrimary"
app:layout_constraintBottom_toTopOf="@+id/list_text_secondary"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
tools:ignore="Deprecated"
tools:text="list_text_primary"/>
<TextView
android:id="@+id/list_text_secondary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:gravity="center_vertical"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.ListSecondary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/list_text_primary"
tools:ignore="Deprecated"
tools:text="list_text_secondary"/>
</android.support.constraint.ConstraintLayout>
I've also tried to set the LayoutParams manually in onCreateViewHolder as described here. I thought it worked but from time to time the parent will have a 0 width and height (I'm unable to pinpoint the reason) causing the child to become invisible.
According to this answer the RecyclerView should already me measured by the time onCreateViewHolder is called.