I'm using `AndroidViewBinding` with a `FragmentCon...
# compose
e
I'm using
AndroidViewBinding
with a
FragmentContainerView
(as outlined in the interop docs) while converting my app from a Fragment based to Compose based. Everything seems to be working pretty well, except that on the first screen/fragment if I background the app by pressing the home button, when I reopen the app I have to touch the screen once before any further touches are registered (i.e. I click the button to move to the next screen but nothing happens not even the ripple animation, then I click again and it works fine). This doesn't happen if I background the app by turning the screen off with the app open, and it only happens on this first screen. If I migrate that screen fully away from Fragments it works fine. All the listeners etc... are being set up correctly both initially and when resuming. Anyone experience anything like this?
Looks like it is related to gesture nav https://issuetracker.google.com/issues/185228754
s
we have faced similar issue in ViewPager2 in our project. Probably both could be same. This is the commit message for the fix - Fragment.kt - Fix for ViewPager2 fragment UI state frozen issue -
Copy code
* steps to reproduce - add about 10 fragments in ViewPager2, navigate items one by one by clicking tab
                     * The UI state will be incomplete for some fragments. The view state that has been made before onResume calls won't be drawn
                     * No issues in fragment lifecycle and fragment view lifecycle call back
                     * No issues in root view callback and state - view height is expected one, onAttach is called
                     * On checking code, haven't found issues in FragmentStateAdapter too
                     * After lots of trial and errors, found the following workaround works fine. Note, it doesn't works when the top most view is requested for layout
                     requestLayout - onMeasure and onLayout will be called
and this is the fix
Copy code
override fun onResume() {
        super.onResume()
(requireView() as ViewGroup).getChildAt(0).requestLayout()