When we want to change the view from Linear to Grid and viceversa we use recyclerView.setLayoutManager(layoutManager)
.
But how do we know that a new LayoutManager is set?
I've seen we have the method LayoutManager.onAttachToWindow(rv)
and that this method is called inside setLayoutManager()
but this means that we have to override that method and use our own LayoutManager.
Using addOnLayoutChangeListener()
it works but it is called too often and for others purposes.
Is there a way to listen that a new Layout has been set?