[英]How can I use horizontal scrolling of a webview inside the viewpager?
您可以在 Git 上查看此演示,并在 viewpager 内水平滚动 webview。
https://github.com/plusinfosys-global/Webview-Inner-Horizontalscroll-with-Viewpager
很有可能,您必须在视图寻呼机上定义自定义滚动,我有这样的示例。 只需在TestViewPager
class 上从您 webview 调用方法canScrollHorizontally
ntally
class TestViewPager(context: Context, attrs: AttributeSet?) : ViewPager(context, attrs) {
override fun canScroll(v: View?, checkV: Boolean, dx: Int, x: Int, y: Int): Boolean {
return if (v is WebView) {
v.canScrollHorizontally(-dx)
} else {
super.canScroll(v, checkV, dx, x, y)
}
}
}
您可以使用此方法在滚动当前视图时锁定任何其他滚动视图。 尝试这个,
public static void LockScrollViewOnViewTouch(final ScrollView scrollView, View view) {
view.setOnTouchListener(new android.view.View.OnTouchListener() {
@SuppressLint("ClickableViewAccessibility")
public boolean onTouch(View p_v, MotionEvent p_event) {
scrollView.requestDisallowInterceptTouchEvent(true);
return false;
}
});
scrollView.setOnTouchListener(new android.view.View.OnTouchListener() {
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View v, MotionEvent event) {
scrollView.requestDisallowInterceptTouchEvent(false);
return false;
}
});
}
此禁用触摸滚动,第一个参数“scrollview”是您要锁定的视图,可能是您的 viewPager。 让我知道它是否有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.