4

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 2

5

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, that delay statement fixed some weird behavior i kept seeing
Why do we need delay ?
-3

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

I use compose, compose is working without xml :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.