Honeycomb (3.1) adjustmentResize 不再工作?

发布于 2024-11-18 18:24:53 字数 2339 浏览 2 评论 0原文

我的活动有 android:windowSoftInputMode="adjustResize" 并在 Android 2.1 中进行相应的行为:

在软键盘出现之前

在软键盘出现之前">

2.1 中的键盘行为(好)

但是,在 Honeycomb 中,软键盘不会调整我的大小布局,它改为覆盖按钮:

Honeycomb 中的键盘行为(坏)

10 英寸 Galaxy 选项卡和 10 英寸 Galaxy 选项卡上的行为相同摩托罗拉 Xoom。

我已经多次修改我的布局,试图让它与 Honeycomb 兼容,但没有成功。软键盘将向上推 EditText 视图,但不会向上推按钮。

这是一个演示该问题的简单应用项目。

< strong>编辑:链接已修复。

使用的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:layout_alignParentBottom="true">
        <Button
            android:id="@+id/save"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Save" />
        <Button
            android:id="@+id/cancel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Cancel" />
    </LinearLayout>
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true">
        <EditText
            android:layout_height="wrap_content"
            android:layout_width="fill_parent" />
    </ScrollView>
</RelativeLayout>

我发现的唯一相关问题是 这个,但是禁用硬件加速对我没有任何影响。我还阅读了 有关使应用程序兼容的 Android 指南使用输入法,但无法识别那里的任何解决方案。

我做错了什么吗?或者这是一个错误,有人有更多信息吗?

My activity has android:windowSoftInputMode="adjustResize" and behaves accordingly in Android 2.1:

Before soft keyboard appears

Before soft keyboard appears

With keyboard

Keyboard behavior in 2.1 (good)

However, in Honeycomb the soft keyboard does not resize my layout, it instead covers the buttons:

Keyboard behavior in Honeycomb (bad)

Same behavior on both the 10 inch Galaxy tab and the Motorola Xoom.

I've reworked my layout several times trying to get it to be compatible with Honeycomb, to no avail. The soft keyboard will push up an EditText view, but not the buttons.

Here is a simple app project demonstrating the problem.

Edit: Link fixed.

The layout used:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:layout_alignParentBottom="true">
        <Button
            android:id="@+id/save"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Save" />
        <Button
            android:id="@+id/cancel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Cancel" />
    </LinearLayout>
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true">
        <EditText
            android:layout_height="wrap_content"
            android:layout_width="fill_parent" />
    </ScrollView>
</RelativeLayout>

The only related issue I've found is this, but disabling hardware acceleration had no effect for me. I also read the Android guide on making your app compatible with input methods, but didn't recognize any solution there.

Am I doing something obviously wrong? Or is this a bug anyone has more info on?

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

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

发布评论

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

评论(3

陪你搞怪i 2024-11-25 18:24:53

您好,我已经检查了您的代码。

请删除“AndroidManifest.xml”中的以下行

android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"

,然后检查并调整屏幕大小。

如果有任何疑问请告诉我。

Hi I have checked your code.

please remove below line in "AndroidManifest.xml"

android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"

and then check then adjust size your screen.

If any query plz let me know.

ま柒月 2024-11-25 18:24:53

adjustResize 模式绝对有效;您将在整个 UI 中看到它的运行情况。

所以问题是:为什么没有为您的应用程序设置它?

首先,您可以使用“adb shell dumpsys window”查看有关窗口的信息,其中包括由其 WindowManager.LayoutParams 设置的软输入模式。那里打印的值是原始数字;在这里查看其含义: http://developer.android.com /reference/android/view/WindowManager.LayoutParams.html#SOFT_INPUT_ADJUST_NOTHING

如果您的窗口实际上没有 adjustmentResize,那么您需要深入研究并了解为什么没有设置。其他一切正常,如果您在活动上设置该模式,它将像往常一样在窗口上设置。您需要查找正在执行的其他操作,导致窗口中的内容发生更改。

如果您的窗口确实选择了 adjustmentResize,那么由于某种原因,您的视图层次结构实际上并未调整大小。据我所知,平台中没有重大差异可能会导致此功能不起作用(并且您可以再次看到它在库存 UI 的其他地方确实有效)。我建议在这里做的第一件事是使用 HierarchyViewer 来查看视图层次结构中发生的情况。

The adjustResize mode definitely works; you will see it in action throughout the UI.

So the question is: why is it not being set for your app?

First thing you can use "adb shell dumpsys window" to see the information about your window, which will include the soft input mode being set by its WindowManager.LayoutParams. The value printed there is the raw number; look here for its meaning: http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#SOFT_INPUT_ADJUST_NOTHING

If your window does not actually have adjustResize there, then you'll need to dig in and see why that is not getting set. Everything else being normal, if you set that mode on the activity it will be set on the window like always. You'll want to look for something else you are doing that is causing it to be changed in your window.

If your window does have adjustResize selected, then for some reason your view hierarchy is not actually resizing. There are no major differences I know of in the platform that could cause this to not work (and again you can see that it does work elsewhere in the stock UI). The first thing I would suggest doing here is using HierarchyViewer to see what is happening in your view hierarchy.

爱人如己 2024-11-25 18:24:53

当您的 Activity 处于全屏模式时,调整调整大小将失败,如下所示:https://code.google.com/p/android/issues/detail?id=5497&can=1&q=honeycomb%20fullscreen&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars

我找到了一个对我有用的解决方法,你可能想尝试一下:
https://stackoverflow.com/a/19494006/1241783

干杯

adjustResize will fail when your activity is in fullscreen mode, as tracked here: https://code.google.com/p/android/issues/detail?id=5497&can=1&q=honeycomb%20fullscreen&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars

I found a workaround which worked for me, you might want to try out:
https://stackoverflow.com/a/19494006/1241783

Cheers

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