There is a dialog with custom view containing
EditText
as shown below in Typing Hero.![notion image](https://cdn.feather.blog?src=https%3A%2F%2Fusenotioncms.com%2Fproxy%2Fblock%2Ff7b6bb9b-301f-4407-a583-2dbea1f94148%252F450c7c70-e4a4-4cc7-8c36-6a1d2078bb28%252FUntitled.webp&optimizer=image&quality=80&width=280)
You would call
window?.setSoftInputMode(SOFT_INPUT_STATE_VISIBLE)
so user can access the keyboard right away as it shows up.However, calling
window?.setSoftInputMode(SOFT_INPUT_STATE_VISIBLE)
before dialog.show()
can make the view below EditText
not visible.![notion image](https://cdn.feather.blog?src=https%3A%2F%2Fusenotioncms.com%2Fproxy%2Fblock%2F39be2eef-1bd3-4947-bad7-885034a250dc%252F5d639fa3-2bfc-4efd-b80f-4d4b299b09de%252FUntitled.webp&optimizer=image&quality=80&width=280)
![notion image](https://cdn.feather.blog?src=https%3A%2F%2Fusenotioncms.com%2Fproxy%2Fblock%2Ffcd9d82a-18ae-45fd-9d45-4b1555f8c5d0%252Fd2f15d13-9ef9-4355-b606-a948e315d68e%252FUntitled.webp&optimizer=image&quality=80&width=280)
Apparently,
setSoftInputMode
eventually updates the view’s layout which is not yet visible.![notion image](https://cdn.feather.blog?src=https%3A%2F%2Fusenotioncms.com%2Fproxy%2Fblock%2F2c8f040e-f256-473f-b20b-98c94c7c5e70%252Fa0b0148d-153e-45cf-ad2d-e7b3fc82e597%252FUntitled.webp&optimizer=image&quality=80&width=280)
![notion image](https://cdn.feather.blog?src=https%3A%2F%2Fusenotioncms.com%2Fproxy%2Fblock%2F8c1cd700-c1e6-4735-9664-81b76076edaa%252F191f2963-12d1-45c9-9337-db038d284cca%252FUntitled.webp&optimizer=image&quality=80&width=280)
To prevent that from happening, call
dialog.show()
before window?.setSoftInputMode(SOFT_INPUT_STATE_VISIBLE)
.Maybe it’s worth to mention that this is happening on physical device and NOT not on emulator.