Add RecyclerView body

Can I use RecyclerView as a parent element for other views declared in XML?

<android.support.v7.widget.RecyclerView ... >
    <TextView ... />
    <ImageView ... />
</android.support.v7.widget.RecyclerView>

Something like this. I need this in order to get my collapsing toolbar working with main content on my activity.

Answers


You have to use a RecyclerView.Adapter with RecyclerView. But items in RecyclerView.Adapter can have different viewType just like ListView. With this feature you can achieve something like HeaderView in RecyclerView and FooterView in RecyclerView, and make these views scroll with your items.


No, You can't add any child view inside Recycler View. See the example https://github.com/javatechig/Android-RecyclerView-Example.


Create separate .xml file (e.g. single_recycler_view_row.xml) and use it to build layout for single RecyclerView item. Then you need to create an adapter and pass single_recycler_view_row.xml as a parameter.

To make sure that your RecyclerView works well with CollapsingToolbarLayout add

app:layout_behavior="@string/appbar_scrolling_view_behavior" />

attribute to RecyclerView.


Need Your Help

How to adjust time scale axis for ggplot histogram

r plot ggplot2

I am working with a data frame where one of the columns consists of POSIXct date-time values. I am trying to plot a histogram of these timestamps using ggplot2 but I'm having two issues:

filtering query for django mongoengine

python django mongoengine flask-mongoengine

I have two views with embedded document and list field and need filteringquery