I have a view pager type FragmentStateAdapter
and would like to know when the primary fragment is in position e.g. 100% visible. Does FragmentStateAdapter
even support this? I've already tried approaches on this post with no luck.
Each fragment in the pager has some control over the host activity, but the control must be mutually exclusive. So like for example depending on which fragment is 100% visible, a button in the host activity layout will change color. But the color must depend on which fragment is primary, not on which fragment is resumed (adjacent fragment which are not visible can be in resumed state for example).
I am using ViewPager2
and the widget class.
edit
Maybe an alternative is use like a global layout change listener to test if the root layout of the fragment is 100% displayed?