Textfield in AlertDialog in jetpack compose goes out of dialog layout when entering too much time

Viewed 496

I'm using kotlin and jetpack compose. My Alert Dialog has a TextField at bottom, when I press enter too much time on keyboard, the text field gets longer height and it go outside of the dialog. How can I limit it to not enter out of alert layout? I have set maxlines but the layout get white space at top. please see the code below and image

Column(
                Modifier
                    .background(Color.White)
                    .wrapContentHeight()
                    .verticalScroll(rememberScrollState())
                    .pointerInput(Unit) {
                        detectTapGestures(onTap = {
                            focusManager.clearFocus()
                        })
                    }
            )
TextField(
    modifier = Modifier
        .fillMaxWidth()
        .wrapContentSize(),
    value = text.value ?: "-",
    onValueChange = {
        isExceed = it.filter { char -> char == '\n' }.count() > maxLine
        text.value = it 
        onValueChange(it)
    },
    //maxLines = maxLine,
    placeholder = {
        Text(text = NfcApp.str(textHint, ResEnum.refrigerant))
    },
    keyboardActions = KeyboardActions(
        onDone = { keyboardController?.hide() }
    ),
    colors = TextFieldDefaults.textFieldColors(
        textColor = Color.Black,
        backgroundColor = Color.White,
        cursorColor = underLine_green,
        disabledIndicatorColor = underLine_green,
        unfocusedIndicatorColor = underLine_green,
        focusedIndicatorColor = underLine_green
    )
))

enter image description here

0 Answers
Related