Android Froyo WebView doesn't scroll vertically

纵然是瞬间 提交于 2019-12-24 04:13:11

问题


I have a WebView widget in my app that displays custom HTML content. This is my layout:

<?xml version="1.0" encoding="utf-8"?>    
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/main_article_view"
 >
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="56dp"
    android:background="@drawable/header_background">

<Button 
    android:id="@+id/article_next"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:background="@drawable/right_segment"
    android:layout_centerVertical="true"
    android:layout_alignParentRight="true"
    android:layout_marginRight="2dip"
/>

<Button 
    android:id="@+id/article_previous"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:background="@drawable/left_segment"
    android:layout_centerVertical="true"
    android:layout_alignBaseline="@id/article_next"
    android:layout_toLeftOf="@id/article_next"
/>



<ImageView 
    android:layout_width="wrap_content"
    android:id="@+id/article_nav_logo" 
    android:layout_height="wrap_content"
    android:background="@drawable/app_logo"
    android:layout_toLeftOf="@id/article_previous"
    android:layout_centerVertical="true"
    android:layout_marginRight="15dp"/>

</RelativeLayout>

<com.myapp.android.NavBar
    android:id="@+id/vertical_navbar"
    android:layout_width="fill_parent"
    android:layout_height="45dp"
/>


<WebView
        android:id="@+id/webkit"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
/>


</LinearLayout>

The code is really simple - the class that handles the layout also implements the WebViewClient methods. It loads the html data into the WebView.

The app works well on all OS's except Froyo. On Froyo the WebView doesn't respond to vertical scroll event - it can scroll horizontally though.

I had a onFling event listener - which has been disabled, but still no luck. Any help/hint is greatly appreciated. Thanks.


回答1:


The moment you ask the question.... I found the issue and Im not sure if it is related to WebView. In my html template I have this

<meta name = "viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

This setting will cause the WebView to freeze up on Froyo. Later I found this Building web pages to support different screen densities and this question on stackoverflow. Hope it helps someone else down the line.



来源:https://stackoverflow.com/questions/3085630/android-froyo-webview-doesnt-scroll-vertically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!