android 禁止webview滚动

来源:互联网 发布:美国程序员平均工资 编辑:程序博客网 时间:2024/05/16 11:51

由于需求原因,该webview加载的内容需要显示在制定位置,但是返回的图片可以自由在该webview中间滑动 

解决方法:在webview外层加上ScrollView ,这样,两者的滑动事件会冲突,只要设定外层的宽高度,滑动事件就不会分发到webview


<ScrollView
            android:id="@+id/scrollView1"
            android:layout_gravity="center_horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >


            <LinearLayout
                android:id="@+id/webview_parent"
                android:layout_width="@dimen/main_w"
                android:layout_height="@dimen/main_h"
                android:layout_marginTop="5dp"
                android:orientation="vertical" >


                <WebView
                    android:id="@+id/btn5"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scrollbars="none" />
            </LinearLayout>
        </ScrollView>

0 0
原创粉丝点击