最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - When I click on TextField the Floating Action Button hides behind Keyboard - Stack Overflow

programmeradmin2浏览0评论
@Composable
fun AddNoteUi(viewModel: AddNotesViewModel = koinViewModel()) {

        val state by viewModel.state.collectAsState()

    Scaffold(
        modifier = Modifier.fillMaxSize(),
        containerColor = colorResource(R.color.black),
        contentColor = colorResource(R.color.white),
   
        floatingActionButton = {
            FloatingActionButton(
                shape = CircleShape,
                modifier = Modifier.padding(5.dp),
                onClick = {
                    navController.popBackStack()
                },

                contentColor = colorResource(R.color.white),
                containerColor = colorResource(R.color.purple_700)
            ) {
                Icon(
                    imageVector = Icons.Rounded.Save,
                    contentDescription = "Save"
                )
            }
        },
    ) { innerPadding ->

        Column (
            modifier = Modifier
                .fillMaxSize().padding(innerPadding)
        ) {

                CustomTextField(
                    value = state.note.title,
                    hint = "Title",
                    onValueChange = {
                        viewModel.setTitle(it)
                    },
                    modifier = Modifier
                        .fillMaxWidth()
                        .padding(bottom = 8.dp) // Add spacing between TextFields
                )

                CustomTextField(
                    value = state.note.message,
                    hint = "Description",
                    onValueChange = {
                        viewModel.setMessage(it)
                    },
                    modifier = Modifier.weight(1f)
                        .fillMaxWidth()
                )
            }
        }


    }

I tried using imePadding in the column but the FloatingActionButton still hides behind the keyboard. When I click on any of the CustomTextField, the FloatingActionButton should move above the keyboard layout. When any of CustomTextField is unfocused, the FloatingActionButton should come to its previous position.

发布评论

评论列表(0)

  1. 暂无评论