【问题标题】:Android Froyo WebView doesn't scroll verticallyAndroid Froyo WebView 不会垂直滚动
【发布时间】:2010-06-21 14:42:46
【问题描述】:

我的应用中有一个显示自定义 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 事件监听器 - 它已被禁用,但仍然没有运气。非常感谢任何帮助/提示。谢谢。

【问题讨论】:

    标签: android android-widget android-webview


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-07
      • 2011-11-19
      • 1970-01-01
      • 1970-01-01
      • 2021-04-04
      • 1970-01-01
      相关资源
      最近更新 更多