Android 水平滚动时,禁用特定视图的垂直滚动

Android 水平滚动时,禁用特定视图的垂直滚动,android,webview,scrollview,Android,Webview,Scrollview,我在scrollview中有一个WebView,我想让用户体验到WebView中的滚动-当您开始水平滚动时>我想关闭垂直滚动。相反。我尝试了这个解决方案: 但它完全禁用了垂直滚动的网络视图,所以我不能向上或向下滚动 我的代码: package com.tachles; import android.os.Bundle; import android.text.Html; import android.text.Spanned; import android.view.Menu; import

我在scrollview中有一个WebView,我想让用户体验到WebView中的滚动-当您开始水平滚动时>我想关闭垂直滚动。相反。我尝试了这个解决方案: 但它完全禁用了垂直滚动的网络视图,所以我不能向上或向下滚动

我的代码:

package com.tachles;

import android.os.Bundle;
import android.text.Html;
import android.text.Spanned;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.WebView;
import android.widget.LinearLayout;
import android.widget.ListView;

public class History_04_01 extends TextSet {

    WebView myweb;
    LinearLayout ll1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        String formattedText = getString(R.string.buildcountry01);
        ll1 = (LinearLayout) findViewById(R.id.linear2);
        Spanned result = Html.fromHtml(formattedText);
        text.setText(result);

        myweb = new WebView(this);
        myweb.loadUrl("file:///android_asset/tavla.png");
        ll1.addView(myweb);

        // your HorizontalScrollView inside scrollview
        myweb.setOnTouchListener(new ListView.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                int action = event.getAction();
                switch (action) {
                case MotionEvent.ACTION_DOWN:
                    // Disallow ScrollView to intercept touch events.
                    v.getParent().requestDisallowInterceptTouchEvent(true);
                    break;

                case MotionEvent.ACTION_UP:
                    // Allow ScrollView to intercept touch events.
                    v.getParent().requestDisallowInterceptTouchEvent(false);
                    break;
                }

                // Handle HorizontalScrollView touch events.
                v.onTouchEvent(event);
                return true;
            }
        });

    }

    public void sizeUp(MenuItem item) {

        super.sizeUp(item);
    }

    public void sizeDown(MenuItem item) {

        super.sizeDown(item);

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.textbar, menu);
        return true;
    }

    @Override
    protected void onStart() {
        super.onStart();

    }

    @Override
    protected void onStop() {
        super.onStop();

    }
}
以及XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relative1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" >

        <RelativeLayout
            android:id="@+id/linear1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="right"
                android:gravity="right" />

            <LinearLayout
                android:id="@+id/linear2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textView1"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:orientation="vertical" >
            </LinearLayout>
        </RelativeLayout>
    </ScrollView>

</RelativeLayout>

四年了,仍然没有答案: