【发布时间】:2019-11-07 06:43:48
【问题描述】:
我在我的 webview 中打开了 Stack Overflow 的解决方案,因此该页面的移动版本在 webview 中打开。现在有一个代码需要水平滚动才能完全查看。当我开始滚动时,我的 webview 也开始滚动。因此,网页上不会发生滚动,而 viewPager 会发生滚动。
我试过这个,但是当我实现这个时,我的刷卡被完全禁用了。 How do disable paging by swiping with finger in ViewPager but still be able to swipe programmatically? 我不知道如何实现。
<LinearLayout android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true"
xmlns:android="http://schemas.android.com/apk/res/android" >
<LinearLayout
android:id="@+id/urlBoxId"
android:background="@color/colorPrimaryDark"
android:elevation="4dp"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/editTextId"
android:layout_marginHorizontal="3dp"
android:background="@drawable/rectangle"
android:paddingHorizontal="10dp"
android:paddingVertical="8.5dp"
android:textColor="#fff"
android:hint="EnterUrl"
android:inputType="textUri"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="6"/>
</LinearLayout>
<WebView
android:id="@+id/webViewId"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
这是我的片段布局。我在 webview 上方有一个线性布局。我想在 webview 上滑动时禁用 viewPager 滑动,但在 linearLayout 上滑动时能够滑动片段。
我对 Android 还是很陌生。
【问题讨论】:
-
感谢@TariqulIslam。但我是否必须扩展我的 webview。因为到目前为止我们有 canScrollHorizontally()。但是,当我尝试这种方法时,它没有用。这种方法也适用于网页内的滚动视图吗?
-
该解决方案 @TariqulIslam 不起作用
标签: android android-fragments webview android-viewpager