Tuesday, August 11, 2015

WebView 内嵌了 Web 的页面, 但是表单的input 没有任何的效果?

原来是因为,焦点问题:
我在给WebView 设置的时候设置了:
webview.setRequestFocusFromTouch()  只有出发的时候 才会 获取焦点,相当于将 Web 页面的焦点给拦截了。

/** * Call this to try to give focus to a specific view or to one of its descendants. This is a * special variant of {@link #requestFocus() } that will allow views that are not focuable in * touch mode to request focus when they are touched. * * @return Whether this view or one of its descendants actually took focus. * * @see #isInTouchMode() * */public final boolean requestFocusFromTouch() {
    // Leave touch mode if we need to    if (isInTouchMode()) {
        ViewRootImpl viewRoot = getViewRootImpl();        if (viewRoot != null) {
            viewRoot.ensureTouchMode(false);        }
    }
    return requestFocus(View.FOCUS_DOWN);}

No comments:

Post a Comment