gpt4 book ai didi

android - EditText.getLocationOnScreen() 为 2 个不同的位置返回相同的结果

转载 作者:太空狗 更新时间:2023-10-29 15:17:21 30 4
gpt4 key购买 nike

我有一个带有 EditTextdialog,当用户点击它时,软键盘出现并将 dialog 向上推(以免隐藏)。当键盘关闭时,EditText 恢复其原始位置。这是标准行为。 EditText 明显移动了,但调用 getLocationOnScreen()getBottom() 等对两个位置返回相同的结果。我在这里遗漏了什么还是这是 Android 中的错误?

顺便说一句,我问的原因是因为这种行为导致我们的一些 Robotium 测试失败,因为 Robotium 依赖 getLocationOnScreen() 来计算点击位置。

最佳答案

您需要在 AndroidManifest.xml 文件中将 android:windowSoftInputMode="adjustResize" 添加到您的标签中

看看这个

Android: show soft keyboard automatically when focus is on an EditText

这肯定会对你有所帮助。

谢谢:)

关于android - EditText.getLocationOnScreen() 为 2 个不同的位置返回相同的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11610920/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com