New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 912610 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Feature



Sign in to add a comment

SOFT_INPUT_ADJUST_PAN does not work for input fields in WebView

Project Member Reported by changwan@chromium.org, Dec 6

Issue description

Expected behavior:

A WebView is hosted on a Window that has SOFT_INPUT_ADJUST_PAN, then contents will not be shifted up as it implies.

Actual behavior:

I guess this has never worked in practice.


Repro code:

----
package com.google.corp.b.bug115528561;

import android.app.Activity;
import android.os.Bundle;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.WebView;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

        final StringBuilder sb = new StringBuilder();
        sb.append("<html>");
        sb.append("  <form>");
        for (int i = 0; i < 100; ++i) {
            sb.append("<input type=\"text\" style=\"font-size:xx-large\" name=\"input")
                    .append(i).append("\"><br>");
        }
        sb.append("  </form>");
        sb.append("</html>");
        final String html = sb.toString();

        final WebView webView = new WebView(this);
        webView.setLayoutParams(new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        webView.loadData(html, "text/html; charset=UTF-8", null);
        setContentView(webView);
    }
}



By comparison, the following works on EditText:

package com.google.corp.b.bug115528561expected;

import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.LinearLayout;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

        final EditText editText = new EditText(this);

        final LinearLayout layout = new LinearLayout(this);
        layout.setOrientation(LinearLayout.VERTICAL);
        layout.setGravity(Gravity.BOTTOM);
        layout.addView(editText);

        setContentView(layout);
    }
}

Internally SOFT_INPUT_ADJUST_PAN is implemented in ViewRootImpl.java with an assumption that the focused View directly or indirectly triggers ViewRootImpl#requestChildRectangleOnScreen().  EditText/TextView does this by internally calling TextView#bringPointIntoView() from TextView#{onPreDraw(), onLayout(), updateAfterEdit()}.  WebView, however, does not have things like TextView#bringPointIntoView().  As a result, SOFT_INPUT_ADJUST_PAN will be ignored while interacting with WebView.

Making this a feature request as it never worked in practice.

Originally filed as b/115528561
 
b115528561_expected.mp4
5.0 MB View Download
Owner: ctzsm@chromium.org
Status: Assigned (was: Available)
assigning to ctzsm@ for backlog
See b/27133109 internally also which is a similar/same issue about not using requestRectangleOnScreen when we probably should.

Sign in to add a comment