I am make my app compatible to multi-window and PIP(Picture in Picture).
I have a Recycler View which is of Type GridLayout Holder having TextView and ImageView for each View Holder.
I am giving my Holder's dimension's in DP
(just for info i.e it should resize based on new size of window) and by default the recyclerView in not handling the onSizeChanged()
call. So I Created a customRecycler to handle onSizeChanged()
call's. But i am not sure how to handle the size change of recyclerView as on Size Change i should re-render all View-holder also(just guessing).
class CustomRecyclerView : RecyclerView {
constructor(context: Context) : super(context)
constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet)
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
/*
post {
requestLayout() // forcing relayout but this also doesn't work with or without post.
}
*/
}
}
If i am starting the app in Full screen and and then switching to PIP. then result is below.
The issue here that i understood is the Recycler View when the size is changed is not re-rendering/re-layouting the whole view the the size of the Viewholder holder in not updated when the size of the Application window is changed.
What approach should i use to force recyclerView to adjust according to new screen size?