2

Is it possible to add some Views above and between the rows in the RowsSupportFragment?

Oleh Liskovych
  • 991
  • 3
  • 13
  • 31

1 Answers1

3

It is possible to add any view above the rows by adding view to parent FrameLayout of VerticalGridView in onViewCreated method. To give space for this view, set proper value for verticalGridView.windowAlignmentOffsetPercent:

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        (view.parent as? FrameLayout)?.run {
            val myView = LayoutInflater.from(context).inflate(R.layout.my_view_to_add, this, false)
            addView(myView)
        }
        verticalGridView?.let {
            it.windowAlignmentOffsetPercent = 30.0f
        }
    }

This added view is static and won't scroll out when focus goes down.

Between rows it seems there is no way to add anything but ItemDecorator, because VerticalGridView is a descendant of RecyclerView

Oleh Liskovych
  • 991
  • 3
  • 13
  • 31