2

I have a pinned bottom container with a textfield. And i use imePadding modifier. When keyboard appears seems like imePadding works twice. It happens only on some devices. Particular my is Samsung Galaxy A80 (Android 11)

Code example

        Scaffold(
            modifier = Modifier.fillMaxSize(),
            bottomBar = {
                Box(
                    Modifier
                        .imePadding()
                        .height(100.dp)
                        .background(Color.Red),
                ) {
                    BasicTextField(
                        modifier = Modifier.fillMaxWidth(),
                        value = "some text",
                        onValueChange = {},
                    )
                }
            },
        ) {
            Box(
                Modifier.fillMaxSize().padding(bottom = it.calculateBottomPadding()),
            ) {
                LazyColumn(
                    modifier = Modifier.fillMaxSize(),
                ) {
                    repeat((0..100).count()) {
                        item {
                            Box(Modifier.fillMaxWidth().height(100.dp).background(Color.Blue)) {
                            }
                        }
                    }
                }
            }
        }

enter image description here enter image description here

UPD Issue reproduce when I add:

window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
  • Adding some code snippets may help to solve this issue – Sri mani789 Apr 15 '23 at 06:54
  • @Srimani789 here the example When I don't use imePadding on BasicTextField container devices without issue doesn't adjust the screen and there is no padding as expected. But in the same case problematical devices still have imePadding exectly to textfield – Vadim Zhukov Apr 15 '23 at 08:41
  • Hey @VadimZhukov have you managed to resolve your issue? I am observing a similar thing happening on some Samsung devices. – scana May 23 '23 at 11:12
  • @scana nope. Just removed FLAG_LAYOUT_NO_LIMITS flag – Vadim Zhukov May 24 '23 at 12:36

1 Answers1

0

add this line to activity in AndroidManifest.xml file android:windowSoftInputMode="adjustResize". The activity's layout will be resized to ensure that all of its visible content remains visible even when the soft keyboard is shown without using any imePadding() modifiers.

here you can see improved code.

var value by remember { mutableStateOf("") }
Scaffold(
    bottomBar = {
        Box(modifier = Modifier
            .fillMaxWidth()
            .background(MaterialTheme.colorScheme.surface)) {
            OutlinedTextField(
                modifier = Modifier.fillMaxWidth(), value = value,
                onValueChange = { value = it }
            )
        }
    },
) { paddingValues ->
    LazyColumn(
        modifier = Modifier
            .fillMaxSize()
            .padding(paddingValues),
        contentPadding = PaddingValues(12.dp, 16.dp),
        verticalArrangement = Arrangement.spacedBy(4.dp),
    ) {
        items(100) {
            Card(modifier = Modifier.fillMaxSize()) {
                Text(text = "Item $it",  modifier = Modifier.padding(8.dp))
            }
        }
    }
}
Sri mani789
  • 94
  • 1
  • 6