2013-09-30 58 views
0

我已經創建了一個使用jQuery Mobile的webapp,並且我通過webview將其呈現在本地應用程序中。它適用於Android 4+設備,但使用薑餅設備時,滾動根本不起作用。JqueryMobile滾動不能在webview(Android 2.3)中工作

直接在設備的瀏覽器上加載網站確實有效,它只是在我的應用程序的webview上。這就是我如何創建webview:

mWebView = (WebView) findViewById(R.id.webView); 
    mWebView.setFocusable(true); 
    mWebView.setFocusableInTouchMode(true); 
    mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); 
    WebSettings s = mWebView.getSettings(); 
    // s.setUserAgentString(Constants.USER_AGENT); 
    s.setRenderPriority(RenderPriority.HIGH); 
    s.setJavaScriptEnabled(true); 
    s.setDomStorageEnabled(true); 
    s.setDatabaseEnabled(true); 
    s.setAppCacheEnabled(true); 
    s.setSupportZoom(true); 

    s.setBuiltInZoomControls(true); 
    s.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS); 
    s.setUseWideViewPort(true); 
    s.setLoadWithOverviewMode(true); 
    s.setSavePassword(true); 
    s.setSaveFormData(true); 
    s.setJavaScriptEnabled(true); 

有關問題出現在哪裏的任何建議?

回答

0

原來是因爲jQuery Mobile在body上設置了CSS屬性overflow:hidden。我將它設置爲自動爲我的預蜂窩設備,似乎工作正常。

如果有人有興趣,這裏是我使用的是什麼jQuery的:

function isAndroidBelow3() { 
    return !!navigator.userAgent.match(/Android [1-2]/i); 
} 

if(isAndroidBelow3()){ 
    $(document.body).css("overflow", "auto"); 
}