2

我正在尝试像列表视图滑动一样从左到右滑动 Web 视图。我已经按照此处显示的方式进行了操作。

我也设置webviewsviewflipper

<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/flipper" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout>
        <WebView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/webview1" android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
        <WebView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/webview2" android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
    </LinearLayout>

但我认为onTouchEventwebView 在这里不起作用。

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (gestureDetector.onTouchEvent(event))
            return true;
        else
            return false;
    }
4

1 回答 1

1

尝试将您的两个 WebView 从您的 LinearLayout 中移出。ViewFlipper 在其子项之间切换,并且通过您的设置 ViewFlipper 只有一个子项。尝试这个:

<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/flipper" android:layout_width="fill_parent"
android:layout_height="fill_parent">
    <WebView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webview1" android:layout_width="fill_parent"
        android:layout_height="fill_parent" />
    <WebView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webview2" android:layout_width="fill_parent"
        android:layout_height="fill_parent" />
</ViewFlipper>
于 2010-10-09T21:37:37.817 回答