BasicTextField 聚焦时,布局不正确上升

时间:2021-03-17 11:44:05

标签: android android-jetpack-compose

当我点击输入栏时,输入栏被软键盘部分遮挡,而不是完全显示在软键盘上。

这是我的代码:

@Composable
fun ChatBottomBar() {
    var editingText by remember { mutableStateOf("") }
    BasicTextField(
        value = editingText,
        onValueChange = { editingText = it },
        modifier = Modifier
            .fillMaxWidth()
            .padding(4.dp, 8.dp)
            .height(40.dp)
            .clip(MaterialTheme.shapes.small)
            .background(WeTheme.colors.textFieldBackground)
            .padding(start = 8.dp, top = 10.dp, end = 8.dp),
        cursorBrush = SolidColor(WeTheme.colors.iconCurrent)
    )
}

这是屏幕截图,它在我的设备上运行。

The soft keyboard cannot rise correctly!

顺便说一句,当你第一次点击BasicTextField(包括TextField和OutLinedTextField)时,它根本起不来,下面有截图。

the soft keyboard rise only

然后我通过TextField实现了这个,看起来更好但仍然遇到这些问题,有什么想法吗?提前致谢。

1 个答案:

答案 0 :(得分:0)

尝试放置

android:windowSoftInputMode="adjustPan"  

在 AndroidManifest 中添加到您的相应活动。 例如:

<activity
        android:name=".ui.myActivity"
        android:configChanges="keyboard|keyboardHidden|screenSize|screenLayout|uiMode" //for my project
        android:label="mylabel"
        android:launchMode="singleTop"
         android:screenOrientation="landscape"
        android:theme="@style/myTheme"
        android:windowSoftInputMode="adjustPan" />