Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何通过下拉刷新Expo Webview中的页面?_Android_Reactjs_Android Webview_Refresh_Native - Fatal编程技术网

Android 如何通过下拉刷新Expo Webview中的页面?

Android 如何通过下拉刷新Expo Webview中的页面?,android,reactjs,android-webview,refresh,native,Android,Reactjs,Android Webview,Refresh,Native,我用Expo制作了Webview应用程序,观看youtube 起初,我制作了这样的基本应用程序 import * as React from 'react'; import { WebView } from 'react-native-webview'; export default class App extends React.Component { render() { return <WebView source={{ uri: 'https://www.g

我用Expo制作了Webview应用程序,观看youtube

起初,我制作了这样的基本应用程序

import * as React from 'react';
import { WebView } from 'react-native-webview';

export default class App extends React.Component {
  render() {
    return <WebView 
    source={{ uri: 'https://www.google.com' }} 
    allowsFullscreenVideo={true} 
    allowsBackForwardNavigationGestures={true}
    style={{ marginTop: 20 }} />;
  }
}
  • 结论:我需要这些功能
  • 若我触摸Android硬件后退按钮一次,进入后退页面,在很短的时间内两次,结束应用程序。(安卓)
  • 如果我下拉,然后刷新网页。(iOS/Android都有)

  • 您可以将样式添加到滚动和网络视图

    container: {
      position : 'relative',
    },
    ScrollStyle :{
     backgroundColor : 'white',
     position: 'relative',
    }
    
    <View style={{flex: 1}}>
              <ScrollView
                style = {styles.ScrollStyle}
                contentContainerStyle={{flex: 1}}
                refreshControl={
                    <RefreshControl
                      refreshing={false}
                      onRefresh={this.yourFunctionReload} // exl in function : this.yourWebview.reload();
                    />
                }
               >
                    
                <Header />  
                <WebView
                  stylestyle={styles.container}
                  .....
                />
                </ScrollView>
    
    然后渲染ScrollView和Webview

    container: {
      position : 'relative',
    },
    ScrollStyle :{
     backgroundColor : 'white',
     position: 'relative',
    }
    
    <View style={{flex: 1}}>
              <ScrollView
                style = {styles.ScrollStyle}
                contentContainerStyle={{flex: 1}}
                refreshControl={
                    <RefreshControl
                      refreshing={false}
                      onRefresh={this.yourFunctionReload} // exl in function : this.yourWebview.reload();
                    />
                }
               >
                    
                <Header />  
                <WebView
                  stylestyle={styles.container}
                  .....
                />
                </ScrollView>
    
    
    

    注意:不要忘记导入视图、滚动视图、刷新控制和网络视图

    非常感谢!我将应用你的答案。:)
    <View style={{flex: 1}}>
              <ScrollView
                style = {styles.ScrollStyle}
                contentContainerStyle={{flex: 1}}
                refreshControl={
                    <RefreshControl
                      refreshing={false}
                      onRefresh={this.yourFunctionReload} // exl in function : this.yourWebview.reload();
                    />
                }
               >
                    
                <Header />  
                <WebView
                  stylestyle={styles.container}
                  .....
                />
                </ScrollView>