Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help] Scafford is always influenced by ime #38

Closed
SMFDrummer opened this issue Mar 17, 2025 · 2 comments
Closed

[Help] Scafford is always influenced by ime #38

SMFDrummer opened this issue Mar 17, 2025 · 2 comments

Comments

@SMFDrummer
Copy link

What happened?

I'm design my database page with Scafford and OutlinedTextField, but I got a problem: Scafford is always influenced by ime whether I use imePadding modifier or change this bottomBar to content.

SVID_20250318_013525_1.mp4

If I use imePadding modifier, not only the whole Scafford is raised up, but also I got 2x imePadding

SVID_20250318_013558_1.mp4

What should I do? I want the Scafford's topBar and content are static and only bottomBar's bottom (maybe with fab) compat with ime. (Only bottomBar raising up)

My Code

Here is my Scafford segment, if you want the whole project, I'll share it on github.

Scaffold(
        topBar = {
            MedalScreenTopBar(title = "Medal Database", navigator = navigator)
        },
        bottomBar = {
            Row(modifier = Modifier.padding(24.dp).fillMaxWidth().imePadding(), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(16.dp)) {
                OutlinedTextField(
                    modifier = Modifier.weight(8.5f),
                    value = query,
                    onValueChange = { query = it },
                    leadingIcon = { Icon(Icons.Rounded.Search) },
                    singleLine = true,
                    placeholder = { Text("Search Account") },
                    trailingIcon = {
                        if (query.isNotEmpty()) {
                            IconButton(onClick = { query = "" }, variant = IconButtonVariant.Ghost) {
                                Icon(Icons.Rounded.Close)
                            }
                        }
                    },
                    keyboardOptions = KeyboardOptions.Default.copy(
                        imeAction = ImeAction.Search
                    ),
                    keyboardActions = KeyboardActions(
                        onSearch = {
                            keyboardController?.hide()
                        }
                    )
                )
                IconButton(modifier = Modifier.weight(1.5f), onClick = { navigator.navigate(AccountInsertDestination) }) {
                    Icon(Icons.Rounded.Add)
                }
            }
        },
        snackbarHost = {
            SnackbarHost(
                snackBarHostState,
                snackbar = { RenderSnackbar(toastState.type, it) }
            )
        }
    ) { paddingValues ->
        if (users == null) {
            Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
                CircularProgressIndicator()
            }
        } else {
            LazyColumn(modifier = Modifier.padding(paddingValues)) {
                 /* items */
            }
        }
    }
@nomanr
Copy link
Owner

nomanr commented Mar 17, 2025

Can you share your AndroidManifest.xml file? Seems like you are missing "windowSoftInputMode" attribute for the activity.

Try adding android:windowSoftInputMode="adjustResize" to the app's activity in AndroidManifest.xml and imePadding() should work just fine. adjustResize tells the activity to resize when keyboard popups.

@SMFDrummer
Copy link
Author

It works, thank you!

<activity
                android:name=".MainActivity"
                android:exported="true"
                android:windowSoftInputMode="adjustResize"
<!-- Other key-values -->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants