React-native-webview: Android: WebView in loading state takes all the screen (can't set height or position)

Created on 1 Feb 2019  路  1Comment  路  Source: react-native-webview/react-native-webview

We're trying to render a WebView on the screen, leaving a little space at the top for app action bar. However the loading screen from the WebView takes the whole screen, covering the top bar. The same thing happens if we use a custom loading screen (using renderLoading prop) or the default one.

I was looking at react-native-community/react-native-webview#216 thinking as it might be related, however none of the suggestion in that issue helped (setting flex: 0 or flex: null didn't change anything), and this problem occurrs only when it comes to the loading screen and only on Android.

Wat the webview screen looks like:
screen shot 2019-02-01 at 2 05 22 pm
What we expect to see at the top:
screen shot 2019-02-01 at 2 05 47 pm

Code rendering the webview and the loading screen:

render() {
    let content = (
        <WebView style={styles.webView}
                 originWhitelist={['*']}
                 startInLoadingState={true}
                 // renderLoading={this.renderWebViewLoading}
                 source={this.state.request}/>
      );

    return (
      <SafeAreaView style={styles.container}>
        <NavigationEvents
          onWillFocus={() => this.buildWebViewSource()}/>
        <View style={styles.topBar}>
          <TouchableOpacity onPress={this.close}>
            <Nomicon icon={Nomicon.icons.dismiss}
                     allowFontScaling={false}
                     style={styles.closeButton}/>
          </TouchableOpacity>
        </View>
        {content}
      </SafeAreaView>
    );
  }

Styles:

 const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  topBar: {
    height: 30,
  },
  closeButton: {
    marginLeft: 15,
    fontSize: 20,
    color: grey60,
  },
  webView: {
    width: width,
    flex: 1,
  },

});

Most helpful comment

There is a bug since RN 0.57 that makes webview loading overlay everything, just wrap you webview inside a view with overflow: 'hidden'

>All comments

There is a bug since RN 0.57 that makes webview loading overlay everything, just wrap you webview inside a view with overflow: 'hidden'

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kpaulus1997 picture kpaulus1997  路  3Comments

rezvalari picture rezvalari  路  3Comments

chenop picture chenop  路  3Comments

celciusjj picture celciusjj  路  3Comments

apostopher picture apostopher  路  3Comments