我现在简化为最简单的WebView了,还是显示不全,这是怎么回事呢?
roybill opened this issue · comments
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<!--底部评论以上所有内容-->
<com.donkingliang.consecutivescroller.ConsecutiveScrollerLayout
android:id="@+id/csl_case_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical">
<!--这样webview也显示不全-->
<WebView
android:id="@+id/wv_case_detail"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.donkingliang.consecutivescroller.ConsecutiveScrollerLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
这是显示有问题的url,作者可以试试: https://devm.lanfanglian.com/case?id=92 , 直接在电脑网页端是可以完全展示的
这是网页的适配问题。因为WebView通过网页的body计算的内容高度和滑动距离的。而你这个网页的滑动内容不是body,而是body下的detail_container div。导致WebView无法获取到真实的内容高度。这种网页在WebView单独使用的时候,显示上是没有问题的,只是无法监听它的滑动事件。但是在需要解决滑动冲突的页面中就无法使用了,因为它无法拿到滑动的状态,也就没法解决滑动冲突。
这种网页在需要监听滑动状态或者滑动冲突的布局中都会有问题的。比如嵌套在SmartRefreshLayout等布局就不能用了。
那这种情况 应该叫h5怎么去适配呢?还是我们这边去改?
要么就是让H5适配。要么就是android不处理WebView的滑动冲突,但是这样WebView就不能跟其他布局一起联动了。
请问下具体要怎么做的?
如果WebView就不能跟其他布局一起联动,WebView设置app:layout_isConsecutive="false"。如果让H5适配,让H5 body的高度就是WebView的内容高度。