简体   繁体   English

无法滑动网页视图?

[英]can't swipe webview?

I'm trying to get swipe the Web Views like list view swipe.... from left to right. 我正在尝试从左到右滑动Web View,例如列表视图。 I've followed the way that showed here . 我已经按照这里显示的方式进行了操作

Also I've set the webviews in the viewflipper 我也已经在webviews中设置了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">
    <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>

but I think the onTouchEvent of webView does not work here. 但是我认为webView的onTouchEvent在这里不起作用。

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

Try moving your two WebViews out of your LinearLayout. 尝试将两个WebView从LinearLayout中移出。 ViewFlipper switches between its children, and with your setup ViewFlipper has only one child. ViewFlipper在其子级之间切换,并且通过设置,ViewFlipper只有一个子级。 Try this: 尝试这个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM