Android Webview 在 scrollview 内部测试 / 无法滚动
Android Webview examping inside of scrollview / cannot scroll
问题:
滚动条显示了 SPLIT 秒然后就消失了。我可以将 ScrollView
的 height
更改为 100dp
,然后在我可以滚动的小方框中。
在Android Device Monitor
中我可以看到两个元素的高度都是1920。似乎 webview 以某种方式推动其他一切打破他们的 match_parent
规则,因为他们的行为更像 wrap_content
。这是怎么回事?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/speakerBioWebView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="1000dp"></WebView>
</ScrollView>
</LinearLayout>
解决方案
我注意到 Android Studio
对我的设置发出了微弱的警告。该警告在 WebView
的 layout_height
属性下方显示为一条微弱的红线。我将其更改为 match_parent
并关闭了外部 ScrollView
。
这确实是一个疏忽错误,因为警告根本没有引起我的注意。确保查看所有编译器/IDE 警告,看看是否有任何有用的通知。
不确定为什么要在 WebView 周围滚动视图
WebView有自己的滚动条。
问题:
滚动条显示了 SPLIT 秒然后就消失了。我可以将 ScrollView
的 height
更改为 100dp
,然后在我可以滚动的小方框中。
在Android Device Monitor
中我可以看到两个元素的高度都是1920。似乎 webview 以某种方式推动其他一切打破他们的 match_parent
规则,因为他们的行为更像 wrap_content
。这是怎么回事?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/speakerBioWebView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="1000dp"></WebView>
</ScrollView>
</LinearLayout>
解决方案
我注意到 Android Studio
对我的设置发出了微弱的警告。该警告在 WebView
的 layout_height
属性下方显示为一条微弱的红线。我将其更改为 match_parent
并关闭了外部 ScrollView
。
这确实是一个疏忽错误,因为警告根本没有引起我的注意。确保查看所有编译器/IDE 警告,看看是否有任何有用的通知。
不确定为什么要在 WebView 周围滚动视图 WebView有自己的滚动条。