0

I need to show embeded slider (marked green) inside of the list of recyclerview items, like on image below:

enter image description here

I am thinking that I need to change something in my recyclerview layout manager, but I have no idea what exactly and guess it is quite complicated. In addition I am using FlexboxLayout here.

So, could you please help me with the selection of the best approach of solving this problem?

Oleg Kosuakiv
  • 174
  • 2
  • 15

2 Answers2

1

You can inflate different view for that position , since you're inflating a different layout there .

This answer will help :- RecyclerView with multiple view type

The basic gist is to use the getItemViewType and return a flag , say 1 for the first red box , 2 for the second and 3 for the third and inflate layout on depending on the viewType param ( in the signature )

THGRoy
  • 43
  • 11
0

you can resolve it easily to make the layout like this.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@color/recycler_view_item_background_color">

    <!-- Red layout-->
    <LinearLayout
        android:id="@+id/red_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/item_performance_list_padding"
        android:orientation="vertical">

        <TextView
            android:id="@+id/performance_date_text_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=""/>        

    </LinearLayout>

    <!-- Blue Layout-->
    <LinearLayout
        android:id="@+id/blue_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/text_item_divider" />

</LinearLayout>

you can show or hide the blue layout for every item according to your need.

LinearLayout blueLayout = (LinearLayout) findViewById(R.id.blue_layout);
blueLayout.setVisibility(View.GONE); // hide
blueLayout.setVisibility(View.VISIBLE); // show
nexdev
  • 195
  • 11
  • I am sorry, but I don't have blue layout or did not asked about it. In addition I am using recycler view and I want to have it only one. – Oleg Kosuakiv May 22 '19 at 15:09