Implement ImmersionBar in a Fragment
masterDepending on how your Fragment is managed, use one of the following approaches:
- ViewPager2: If using
BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT, call the ImmersionBar initialization directly in the Fragment'sonResume()method. - show()/hide() management: If controlling visibility via
show()andhide(), implement the immersion logic in bothonResume()andonHiddenChanged(boolean hidden)(wherehiddenisfalse). - Fragmentation framework: If using the Fragmentation library, refer to the
FragmentFiveActivityandBaseFiveFragmentexamples in the project demo.