Skewed redering of app on android emulator

I frequently run into this issue, and it is totally random, not predictable. I am running a test on the Android emulator. The emulator is Pixel_4_XL_API_30. When the app is launched in the emulator, it sometimes renders it adequately and at times leaves a gap at the bottom. I have tried to see the reason it so, nut have not. Because of this, the tests are not predictable, and Moreso, only xpath is available for selector options. No resource-id, and ID. Would anyone mind helping me out on this?

This is the right way to render it. Sometimes it renders it this way

This i the skewed way it often renders it. Sometimes it renders it this way.