eygraber
01/16/2023, 7:54 PMAndroidViewBinding
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?eygraber
01/16/2023, 8:36 PMSanjeeviraj M
01/18/2023, 2:23 PM* 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
override fun onResume() {
super.onResume()
(requireView() as ViewGroup).getChildAt(0).requestLayout()