My Recycler Item which inflate in onCreateViewHolder
On a recent API Level currently 25 the height from the recycler in onCreateViewHolder is always empty. This snippet is to set the hight after the recycler view's onMeasure is invoked and set the correct height to the inflated list view.
@Override
public DataBindingViewHolder onCreateViewHolder(final ViewGroup parent, int viewType) {
// You may inflate your view here.
parent.post(new Runnable() {
@Override
public void run() {
int height = parent.getMeasuredHeight() / rows;
View view = holder.getBinding().getRoot();
view.getLayoutParams().height = height;
}
});
return holder;
}