2

我的应用中有一个显示自定义 HTML 内容的 WebView 小部件。这是我的布局:

<?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>

代码非常简单——处理布局的类也实现了 WebViewClient 方法。它将 html 数据加载到 WebView 中。

该应用程序适用于除 Froyo 之外的所有操作系统。在 Froyo 上,WebView 不响应垂直滚动事件——但它可以水平滚动。

我有一个 onFling 事件监听器 - 它已被禁用,但仍然没有运气。非常感谢任何帮助/提示。谢谢。

4

1 回答 1

1

您提出问题的那一刻......我发现了这个问题,我不确定它是否与 WebView 有关。在我的 html 模板中,我有这个

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

此设置将导致 WebView 在 Froyo 上冻结。后来我在 stackoverflow 上发现了这个Building web pages to support different screen densities和这个问题。希望它可以帮助其他人。

于 2010-06-22T14:45:14.860 回答