滚动网页视图滚动视图内 [英] Scroll Webview inside a Scroll View

查看:191
本文介绍了滚动网页视图滚动视图内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有:结果
现在我有一个滚动视图作为父母......这个卷轴视图中,我使用加载一个URL,然后显示在它的文本网页视图..结果
这里是我的xml:

What i have:
Right now i have a Scroll view as a parent...inside this scroll view, i am using a webview that loads a URL and then shows text in it..
Here is my xml:

<ScrollView
    android:id="@+id/parentScroll"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/Heading" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="5dp" >

        <WebView
            android:id="@+id/webView"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:background="@drawable/webview" />
    </RelativeLayout>
</ScrollView>    

我想什么:结果
我想滚动web视图里面it..When我抚摸web视图,可惜父滚动视图被调用..结果
我必须保持父滚动视图也不过除此之外我想,当我在web视图触摸滚动里面的WebView内容。

What i want:
I want to scroll webView inside it..When i touch the webView, unfortunately the parent scroll view gets called..
i have to keep Parent scroll view also but besides this i want to scroll webview content inside it when i touch on webView.

我怎样才能做到这一点?

How can i do this??

推荐答案

创建自定义的触摸拦截网页视图

CustomWebview.java

 package com.mypackage.common.custom.android.widgets

public class CustomWebview extends WebView {

    public CustomWebview(Context context) {
        super(context);
    }

    public CustomWebview(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomWebview(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event){
        requestDisallowInterceptTouchEvent(true);
        return super.onTouchEvent(event);
    }          
}

layout.xml

<com.package.custom.widgets.CustomWebview
                android:id="@+id/view_extra"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                 />

这篇关于滚动网页视图滚动视图内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆