Android:IME 处于活动状态时的布局是什么?

发布于 2024-09-30 13:38:23 字数 1504 浏览 0 评论 0原文

也许有一些背景:当用户单击它时,我试图在可滚动的全屏 EditText 上方显示一个特定的键盘视图。问题是,如果光标位于 EditText 的底部,它会被弹出的键盘视图隐藏。

与常规 IME 视图的明显区别在于,IME 视图将 EditText 推到顶部,并让用户在顶部区域滚动整个 EditText。键盘视图位于底部。一切都是可见且可访问的。这也是我想通过弹出窗口实现的目标。

因此,我的问题是:当常规输入法可见时,布局是什么样的?我不需要动画(如果很难做到,我可以跳过该部分)。

我尝试遍历布局层次结构以查看有什么不同。这是 IME 可见的情况:

root: com.android.internal.policy.impl.PhoneWindow$DecorView
  android.widget.LinearLayout
    android.widget.FrameLayout
      android.widget.TextView
    android.widget.FrameLayout               #1
      android.widget.RelativeLayout
        android.widget.ScrollView
          android.widget.EditText
        com.mytest.KeyboardView

这是没有 IME 且我的弹出视图可见的情况:

root: com.android.internal.policy.impl.PhoneWindow$DecorView
  android.widget.LinearLayout
    android.widget.FrameLayout
      android.widget.TextView
    android.widget.FrameLayout               #1
      android.widget.RelativeLayout
        android.widget.ScrollView
          android.widget.EditText
        com.mytest.KeyboardView

显然,没有区别。 IME 真的丢失了吗?

为了更容易理解,我用“#1”标记了我的应用程序,因此 RelativeLayout 是我的 XML 布局中的根元素。

有人可以帮我吗?如果有人准备好了 XML 样式的布局,我会非常高兴看到它。

更新

到目前为止,我认为我错误地认为 IME 视图会将自身放入活动的布局层次结构中。

与此同时,我试图使 PopupWindow 工作,但无法想出一些方法来解决 EditText 中隐藏光标的问题。

因此,让我问一下:IME 视图是如何出现的,或者它是如何融入到整体显示中的?它如何将自身滚动到编辑字段下方并将编辑字段向上移动并使其按原来的方式滚动?

Maybe some background: I'm trying to have a specific keyboard-view visible above a scrollable full-screen EditText when the user clicks it. The problem is that if the cursor is at the bottom of the EditText it is hidden by the popped up keyboard-view.

The obvious difference to the regular IME-view is that the IME-view pushes the EditText to the top and lets the user scroll the entire EditText in that top area. The keyboard-view sits at the bottom. Everything is visible and accessible. That's what I want to achieve with my pop-up, too.

Therefore, my question is: what does the layout look like when a regular IME is visible? I don't need the animation (if it's hard to do I can skip that part).

I tried to loop through the layout-hierarchy to see what's different. Here's it with IME visible:

root: com.android.internal.policy.impl.PhoneWindow$DecorView
  android.widget.LinearLayout
    android.widget.FrameLayout
      android.widget.TextView
    android.widget.FrameLayout               #1
      android.widget.RelativeLayout
        android.widget.ScrollView
          android.widget.EditText
        com.mytest.KeyboardView

Here it is without the IME and my pop-up view visible:

root: com.android.internal.policy.impl.PhoneWindow$DecorView
  android.widget.LinearLayout
    android.widget.FrameLayout
      android.widget.TextView
    android.widget.FrameLayout               #1
      android.widget.RelativeLayout
        android.widget.ScrollView
          android.widget.EditText
        com.mytest.KeyboardView

Obviously, there's no difference. Is the IME really missing?

For easier understanding I marked my app with "#1", so the RelativeLayout is the root-element in my XML-layout.

Can anyone please help me? If somebody has an XML-style layout ready, I'd be more than happy to see it.

Update

By now I believe that I was wrong in thinking that the IME-view would put itself into the layout-hierarchy of the activity.

In the meantime I was trying to make a PopupWindow work, but couldn't come up with something that would fix the problem with the hidden cursor in the EditText.

Therefore, let me ask this: how does the IME-view appear or how is it woven into the overall display? How does it scroll itself below the editing field and moves the editing field up and makes it scroll the way it does?

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

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

发布评论

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

评论(1

2024-10-07 13:38:23

看来 IME 无法访问。或者至少应用程序无法以任何方式访问它。

我现在有了 EditText 和键盘的相当静态的视图。键盘不会悬停在屏幕上,也没有任何其他奇特的东西。它安装在 EditText 下方。就是这样。它看起来并不引人注目,但我们一致认为用户可能不会输入长篇故事。

It seems that the IME is not reachable. Or at least it's not accessible in any way by the app.

I now have a rather static view of my EditText and the keyboard. The keyboard doesn't hover into screen nor does it any other fancy stuff. It's mounted below the EditText. That's it. It doesn't look spectacular or anything, but we here agreed that the user probably won't enter long stories.

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