I have a TextField in column with verticalScroll(). When adding a large number of characters, the textfield size goes beyond the keyboard and I stop seeing what I am typing I tried to use this lib, but that's doesn't help
2 Answers
I think you can use BringIntoViewRequester in your TextField.
var state by rememberSaveable { mutableStateOf("") } val coroutineScope = rememberCoroutineScope() val bringIntoViewRequester = remember { BringIntoViewRequester() } TextField( value = state, onValueChange = { text -> state = text // This will cause the TextField be repositioned on the screen // while you're typing coroutineScope.launch { bringIntoViewRequester.bringIntoView() } }, modifier = Modifier .bringIntoViewRequester(bringIntoViewRequester) .onFocusChanged { if (it.isFocused) { coroutineScope.launch { delay(400) // delay to way the keyboard shows up bringIntoViewRequester.bringIntoView() } } }, ) See the complete sample here.
2 Comments
TheYogi
Thank you, that delay statement fixed some weird behavior i kept seeing
sarthak gupta
Why do we need delay ?
you can add android:ellipsize="end" and android:maxLines="1" or whatever lines you want, in your text xml hope it would be helpful.
1 Comment
Tus Die
I use compose, compose is working without xml :)