Android构成特定文本字段的伪造键盘

发布于 2025-01-31 08:59:11 字数 385 浏览 4 评论 0原文

我有一个屏幕,其中一些textfields我想显示一个“假”键盘。键盘应该能够拥有我喜欢的任意数量的按钮,并可以按照我想要的方式显示。如下所示。

那么我的问题是如何完成这样的事情?

是否有可能以某种方式覆盖键盘的接口,因此您消耗输入并可以显示“假”键盘ND,然后在单击时删除“假”键盘使用普通键盘的任何其他textfield上的返回按钮?

还是我必须使用自定义回调创建自定义@composable textView ,还可以手动渲染文本光标?

I have a screen where some textfields I want to show a 'fake' keyboard. The keyboard should be able have as many buttons as I like and be displayed however I want. Just as shown below.

My question then is how do you accomplish something like this?

Is it possible to somehow override the interface to the keyboard so you consume the input and can display a 'fake' keyboard nd then remove the 'fake' keyboard when clicking on the back button on any other textfield which uses the normal keyboard?

Or do I have to create a custom @Composable or TextView with custom callbacks, and also render the text cursor manually?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

睫毛上残留的泪 2025-02-07 08:59:11

您可以实现自己的textInputService或提供null以完全禁用默认输入服务:

CompositionLocalProvider(
  LocalTextInputService provides null // or myTextInputService 
) {
    TextField(
        value = text,
        onValueChange = { text = it },
    )
}

其中mytextinputservice shist of:

TextInputService(object : PlatformTextInputService {
    //TODO implement methods
}

You can implement your own TextInputService or provide null to completely disable the default input service:

CompositionLocalProvider(
  LocalTextInputService provides null // or myTextInputService 
) {
    TextField(
        value = text,
        onValueChange = { text = it },
    )
}

where myTextInputService is something like:

TextInputService(object : PlatformTextInputService {
    //TODO implement methods
}
べ映画 2025-02-07 08:59:11

由于localTextInputService现在已弃用,因此您可以尝试使用以下方式:

InterceptPlatformTextInput(interceptor = { _, _ ->
    awaitCancellation()
}) {
    content()
}

Since LocalTextInputService is deprecated now, you can try using this:

InterceptPlatformTextInput(interceptor = { _, _ ->
    awaitCancellation()
}) {
    content()
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文