English 中文(简体)
是否有办法消除网上意见中投入领域的动物群特征?
原标题:Is there a way to disable the zoom feature on input fields in webview?

When a user clicks in an input field or textarea, the application zooms in. Is there a simple way to disable it?

目前有 met子:

meta name="viewport" content="width=device-width; height=device-height; initial-scale=1.0; maximum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi;"

Everything looks great till I look at it on a device with Android 2.2 Specifically HTC Evo 4G.

问题回答

我用这个空档。

你们必须对不同的屏幕大小和电话、已使用的服务器有不同的解决方案。

www.un.org/Depts/DGACM/index_spanish.htm 这是为了达到高科技委员会的愿望,例如:。

<meta content= True  name= HandheldFriendly  />
<meta content= width=640px; initial-scale=0.50; maximum-scale=0.50;minimum-scale=0.50;  name= viewport  />
<meta name="viewport" content="width=640px" />

www.un.org/Depts/DGACM/index_spanish.htm 电话:

<meta name="viewport" content="width=640px,user-scalable=0" />
webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.MEDIUM); 

这一方法已在第19级修订。

这在最后版本4.4.2中进行。

webView.setInitialScale(0);//default,no zoom
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setLoadWithOverviewMode(false);
webView.getSettings().setUseWideViewPort(false);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

这是否只是一个案文化调整问题?

body{ 
    -webkit-text-size-adjust:none; 
}

明确阐述:

android:windowSoftInputMode="adjustPan"

我也想到同样的问题(关于HTC的疏漏), have也找到了好的解决办法。 但是,我确实注意到,如果你使用谷歌移动网站(http://google.com/m)的话。 你们没有这样做,我试图说明为什么会这样。

我先尝试了我可以找到的那套固定装置,包括这一read子和我迄今所发现的任何东西。

一种抗体 我发现,这项工作是为了确定初步比额表,使其达到150(1.5X),然后扩大网站规模,这样,你也就不了解这种分裂行为——可能是因为在你点击案文投入时,它想要达到1.5X的血清水平,如果你重新回到这一动物水平,就没有发生。 但是,这感觉是超标的,很可能是所有电话的坚挺。

在这方面,我如何解决:

在我的所有网页上,我有:

<link rel="stylesheet" media="screen and (-webkit-device-pixel-ratio:0.75)" href="css/ldpi.css" />
<link rel="stylesheet" media="screen and (-webkit-device-pixel-ratio:1)" href="css/mdpi.css" />
<link rel="stylesheet" media="screen and (-webkit-device-pixel-ratio:1.5)" href="css/hdpi.css" />
<meta name="viewport" content="target-densitydpi=device-dpi" />

在投入领域的网页上,我有:

<link rel="stylesheet" media="screen" href="css/mdpi.css" />
<meta name="viewport" content="target-densitydpi=medium-dpi" />

因此,我没有从表格上的 h子中受益,但至少没有动物。

最后,我为我的现实世界项目找到了解决办法。

- MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    WebView mWebView = (WebView) findViewById(R.id.webview);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        mWebView.setOnFocusChangeListener(new MyOnFocusChangeListener(getScale()));
    }
    Log.i(MainActivity.class.getSimpleName(), "getScale: " + getScale());
}

/**
 * Calculate the scale that we need to use manually.
 *
 * @return the scale that we need
 */
private float getScale() {
    DisplayMetrics display = this.getResources().getDisplayMetrics();
    int width = display.widthPixels;
    Float val = Float.valueOf(width) / Float.valueOf(Constants.PAGE_WIDTH);
    return val.floatValue();
}

- MyOnFocusChangeListener.java

public class MyOnFocusChangeListener implements View.OnFocusChangeListener {

    protected float mScale;

    public MyOnFocusChangeListener(float scale) {
        mScale = scale;
    }

    /**
     * Implement this method because we want to apply scale when focus changed.
     * @param v the View we want to apply scale when focus changed.
     * @param hasFocus has a focus or not.
     */
    public void onFocusChange(View v, boolean hasFocus) {
        if (hasFocus) {
            // We must try all cases because mDefaultScale will change on different versions of Android.
            try {
                Field defaultScale = WebView.class.getDeclaredField("mDefaultScale");
                defaultScale.setAccessible(true);
                defaultScale.setFloat(v, mScale);
            } catch (SecurityException e) {
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (NoSuchFieldException e) {
                try {
                    Field zoomManager;
                    zoomManager = WebView.class.getDeclaredField("mZoomManager");
                    zoomManager.setAccessible(true);
                    Object zoomValue = zoomManager.get(v);
                    Field defaultScale = zoomManager.getType().getDeclaredField("mDefaultScale");
                    defaultScale.setAccessible(true);
                    defaultScale.setFloat(zoomValue, mScale);
                } catch (SecurityException e1) {
                    e1.printStackTrace();
                } catch (IllegalArgumentException e1) {
                    e.printStackTrace();
                } catch (IllegalAccessException e1) {
                    e.printStackTrace();
                } catch (NoSuchFieldException e1) {
                    try {
                        Field mProviderField = WebView.class.getDeclaredField("mProvider");
                        mProviderField.setAccessible(true);
                        Object webviewclassic = mProviderField.get(v);
                        Field zoomManager = webviewclassic.getClass().getDeclaredField("mZoomManager");
                        zoomManager.setAccessible(true);
                        Object zoomValue = zoomManager.get(webviewclassic);
                        Field defaultScale = zoomManager.getType().getDeclaredField("mDefaultScale");
                        defaultScale.setAccessible(true);
                        defaultScale.setFloat(zoomValue, mScale);
                    } catch (Exception e2) {
                        e2.printStackTrace();
                    }
                }
            }
        }
    }
}

在网上浏览Classic.java,displaySoftKeybank zooms in and pans, 如果实际比额表低于默认比额表。 网上Wiew有一个领域。 二级 源代码显示,如果你显示软板,则会改变手法。

因此,确保“男性行为”是“的”; 比额表应防止扩大和调整。 (下文是网上意见的来源代码。) java from the grepcode Site - which is no term.)

private void  displaySoftKeyboard(boolean isTextView) {
     InputMethodManager imm = (InputMethodManager)
     getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (isTextView) {
            if (mWebTextView == null) return;
            imm.showSoftInput(mWebTextView, 0);

            if (mActualScale < mDefaultScale) {

                // bring it back to the default scale so that user can enter

                // text.
                mInZoomOverview = false;
                mZoomCenterX = mLastTouchX;
                mZoomCenterY = mLastTouchY;
                // do not change text wrap scale so that there is no reflow
                setNewZoomScale(mDefaultScale, false, false);
                adjustTextView(false);
            }
        }

        else { // used by plugins
            imm.showSoftInput(this, 0);
        }

    }

《https://android.googlesource.com/platform/framework/base/+/a5408e6/core/java/android/webkit/WebViewClassic.java” rel=“nofollow noretinger”>googleSource-WebViewClassic.java ,载于框架/base/core/java/android/webkit/WebClassic.java(用于JellyBean api 17)的类似功能:

/**
 * Called in response to a message from webkit telling us that the soft
 * keyboard should be launched.
 */
private void displaySoftKeyboard(boolean isTextView) {
    InputMethodManager imm = (InputMethodManager)
            mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
    // bring it back to the default level scale so that user can enter text
    boolean zoom = mZoomManager.getScale() < mZoomManager.getDefaultScale();
    if (zoom) {
        mZoomManager.setZoomCenter(mLastTouchX, mLastTouchY);
        mZoomManager.setZoomScale(mZoomManager.getDefaultScale(), false);
    }
    // Used by plugins and contentEditable.
    // Also used if the navigation cache is out of date, and
    // does not recognize that a textfield is in focus.  In that
    // case, use WebView as the targeted view.
    // see http://b/issue?id=2457459
    imm.showSoftInput(mWebView, 0);
}




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签