Gar*_*a C 16 webview react-native react-native-scrollview react-native-android
我想在ScrollView中使用WebView作为我的本机应用程序.但是如果我这样做,我就无法滚动我的webview,除非我在scrollview上禁用滚动.但是,我需要scrollview和webview中的滚动.有关如何完成此任务的任何建议或解决方案?
小智 5
过去 2-3 天我也在互联网上搜索这个问题,我已经找到了一个很棒的解决方案......
npm install --save react-native-webview-autoheight
Run Code Online (Sandbox Code Playgroud)
安装后没有问题
import MyWebView from "react-native-webview-autoheight";
<ScrollView style={{ flex: 1, backgroundColor: "white" }}>
<View
style={{ flex: 1, flexDirection: "column", backgroundColor: "white" }}
pointerEvents={"none"}
>
<Text>Hi I am at top</Text>
<MyWebView
//sets the activity indicator before loading content
startInLoadingState={true}
source={{
uri:
"/sf/ask/3064691101/"
}}
/>
<Text>Hi I am at bottom</Text>
</View>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
它非常适合我..
小智 -1
尝试下一个代码
<ScrollView>
<Text>Text before ScrollView</Text>
<WebView
source={{
uri:
"https://stackoverflow.com/questions/43781301/react-native-how-do-i-scroll-a-webview-inside-scrollview-for-android"
}}
style={{
marginTop: 20,
height: 100
}}
/>
<Text>Text after ScrollView</Text>
<WebView
source={{
uri:
"https://stackoverflow.com/questions/43781301/react-native-how-do-i-scroll-a-webview-inside-scrollview-for-android"
}}
style={{
marginTop: 20,
height: 100
}}
/>
</ScrollView>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6485 次 |
| 最近记录: |