scrollview嵌套webview,导致scrollview不能滑动,怎么解决

qq_27731231 2018-07-10 10:37:46
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/product_detail_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>

<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollview_product"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:fillViewport="true"
android:scrollbars="none">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/y680">

<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="@dimen/y680"></android.support.v4.view.ViewPager>

<View
android:layout_width="match_parent"
android:layout_height="@dimen/y48"
android:layout_alignBottom="@+id/viewPager"
android:alpha="0.3"
android:background="@drawable/icon_gradient_bg"/>

<LinearLayout
android:id="@+id/indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/viewPager"
android:layout_marginBottom="@dimen/y16"
android:gravity="center_horizontal"
android:orientation="horizontal">

</LinearLayout>
</RelativeLayout>

<com.github.lzyzsd.jsbridge.BridgeWebView
android:id="@+id/product_webviiew"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</com.github.lzyzsd.jsbridge.BridgeWebView>

</LinearLayout>
</ScrollView>


<TextView
android:id="@+id/tvBuyItNow"
android:layout_width="match_parent"
android:layout_height="@dimen/y84"
android:layout_centerVertical="true"
android:layout_gravity="bottom"
android:background="@color/btn_redlight"
android:clickable="true"
android:focusable="false"
android:gravity="center"
android:text="立即购买"
android:textColor="@color/white"
android:textSize="14sp"/>

</FrameLayout>
...全文
568 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
键盘舞者113 2018-07-11
  • 打赏
  • 举报
回复
你重写ScrollView类


@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
final float x = ev.getX();
final float y = ev.getY();

final int action = ev.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
mDownPosX = x;
mDownPosY = y;

break;
case MotionEvent.ACTION_MOVE:
final float deltaY = Math.abs(y - mDownPosY);
// 这里是够拦截的判断依据是左右滑动,读者可根据自己的逻辑进行是否拦截
if (deltaY > 5) {
return false;
}
}

return super.onInterceptTouchEvent(ev);
}

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧