react-native trasparent overlay exposing some component












0














how can I create a transparent overlay exposing some component like buttons, icons? So that it can be used as a tutorial screen.



I want to achieve something like shown in the image.



demo tutorial screen










share|improve this question





























    0














    how can I create a transparent overlay exposing some component like buttons, icons? So that it can be used as a tutorial screen.



    I want to achieve something like shown in the image.



    demo tutorial screen










    share|improve this question



























      0












      0








      0







      how can I create a transparent overlay exposing some component like buttons, icons? So that it can be used as a tutorial screen.



      I want to achieve something like shown in the image.



      demo tutorial screen










      share|improve this question















      how can I create a transparent overlay exposing some component like buttons, icons? So that it can be used as a tutorial screen.



      I want to achieve something like shown in the image.



      demo tutorial screen







      react-native overlay






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 23 '18 at 7:40

























      asked Nov 23 '18 at 5:37









      Deepak Verma

      46111




      46111
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You need a modal overlay. To achieve this, you must add a <View> with an opacity style over your current component. In that <View>, you must add your own custom images (with the arrows for example) and position them as you want.



          To add an opacity, you can add a style with the opacity property, like this:



          overlay: {
          opacity: 0.5,
          }


          You can set the value of the opacity as you like (between 0 and 1).



          If you want it to be as big as the screen and to be positioned over your component, you can add something like this:



          overlay: {
          position: 'absolute',
          height: '100%',
          width: '100%',
          backgroundColor: '#fff',
          opacity: 0.5,
          }


          or:



          overlay: {
          position: 'absolute',
          top: 0,
          right: 0,
          bottom: 0,
          left: 0,
          backgroundColor: '#fff',
          opacity: 0.5,
          }


          Now, for the holes in the overlay, that can be achieved by properly using the z-index property. As long as a component has a higher value of z-index, it will be on top of a component that has a lower value.



          To assign the z-index to a style, use it like this:



          onTop: {
          zIndex: 2
          }

          below: {
          zIndex: 1
          }


          Complete example



          This is a working example of a modal overlay, where the text This is always on top, is always on top:



          import React, { Component } from 'react';
          import { Image, StyleSheet, View, Text } from 'react-native';

          export default class App extends Component {
          render() {
          return (
          <View style={styles.container}>
          <Text style={styles.mainText}>This is always on top</Text>
          <View style={styles.overlay}>
          <Text>This is an overlay</Text>
          <Text>This is an overlay</Text>
          <Text>This is an overlay</Text>
          <Text>This is an overlay</Text>
          <Text>This is an overlay</Text>
          <Text>This is an overlay</Text>
          <Text>This is an overlay</Text>
          <Text>This is an overlay</Text>
          </View>
          </View>
          );
          }
          }

          const styles = StyleSheet.create({
          container: {
          flex:1,
          backgroundColor: "#00ff00",
          top: 0,
          right: 0,
          bottom: 0,
          left: 0,
          justifyContent: "center",
          alignItems: "center",
          zIndex: 1
          },
          mainText:{
          fontSize: 30,
          zIndex: 3,
          backgroundColor: '#ff0000',
          },
          overlay: {
          position: 'absolute',
          top: 0,
          right: 0,
          bottom: 0,
          left: 0,
          backgroundColor: '#fff',
          color: '#000',
          opacity: 0.5,
          justifyContent: "center",
          alignItems: "center",
          fontSize: 24,
          zIndex: 2
          }
          });


          Apply these ideas to your working app, and you can achieve what you are looking for.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441141%2freact-native-trasparent-overlay-exposing-some-component%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You need a modal overlay. To achieve this, you must add a <View> with an opacity style over your current component. In that <View>, you must add your own custom images (with the arrows for example) and position them as you want.



            To add an opacity, you can add a style with the opacity property, like this:



            overlay: {
            opacity: 0.5,
            }


            You can set the value of the opacity as you like (between 0 and 1).



            If you want it to be as big as the screen and to be positioned over your component, you can add something like this:



            overlay: {
            position: 'absolute',
            height: '100%',
            width: '100%',
            backgroundColor: '#fff',
            opacity: 0.5,
            }


            or:



            overlay: {
            position: 'absolute',
            top: 0,
            right: 0,
            bottom: 0,
            left: 0,
            backgroundColor: '#fff',
            opacity: 0.5,
            }


            Now, for the holes in the overlay, that can be achieved by properly using the z-index property. As long as a component has a higher value of z-index, it will be on top of a component that has a lower value.



            To assign the z-index to a style, use it like this:



            onTop: {
            zIndex: 2
            }

            below: {
            zIndex: 1
            }


            Complete example



            This is a working example of a modal overlay, where the text This is always on top, is always on top:



            import React, { Component } from 'react';
            import { Image, StyleSheet, View, Text } from 'react-native';

            export default class App extends Component {
            render() {
            return (
            <View style={styles.container}>
            <Text style={styles.mainText}>This is always on top</Text>
            <View style={styles.overlay}>
            <Text>This is an overlay</Text>
            <Text>This is an overlay</Text>
            <Text>This is an overlay</Text>
            <Text>This is an overlay</Text>
            <Text>This is an overlay</Text>
            <Text>This is an overlay</Text>
            <Text>This is an overlay</Text>
            <Text>This is an overlay</Text>
            </View>
            </View>
            );
            }
            }

            const styles = StyleSheet.create({
            container: {
            flex:1,
            backgroundColor: "#00ff00",
            top: 0,
            right: 0,
            bottom: 0,
            left: 0,
            justifyContent: "center",
            alignItems: "center",
            zIndex: 1
            },
            mainText:{
            fontSize: 30,
            zIndex: 3,
            backgroundColor: '#ff0000',
            },
            overlay: {
            position: 'absolute',
            top: 0,
            right: 0,
            bottom: 0,
            left: 0,
            backgroundColor: '#fff',
            color: '#000',
            opacity: 0.5,
            justifyContent: "center",
            alignItems: "center",
            fontSize: 24,
            zIndex: 2
            }
            });


            Apply these ideas to your working app, and you can achieve what you are looking for.






            share|improve this answer


























              0














              You need a modal overlay. To achieve this, you must add a <View> with an opacity style over your current component. In that <View>, you must add your own custom images (with the arrows for example) and position them as you want.



              To add an opacity, you can add a style with the opacity property, like this:



              overlay: {
              opacity: 0.5,
              }


              You can set the value of the opacity as you like (between 0 and 1).



              If you want it to be as big as the screen and to be positioned over your component, you can add something like this:



              overlay: {
              position: 'absolute',
              height: '100%',
              width: '100%',
              backgroundColor: '#fff',
              opacity: 0.5,
              }


              or:



              overlay: {
              position: 'absolute',
              top: 0,
              right: 0,
              bottom: 0,
              left: 0,
              backgroundColor: '#fff',
              opacity: 0.5,
              }


              Now, for the holes in the overlay, that can be achieved by properly using the z-index property. As long as a component has a higher value of z-index, it will be on top of a component that has a lower value.



              To assign the z-index to a style, use it like this:



              onTop: {
              zIndex: 2
              }

              below: {
              zIndex: 1
              }


              Complete example



              This is a working example of a modal overlay, where the text This is always on top, is always on top:



              import React, { Component } from 'react';
              import { Image, StyleSheet, View, Text } from 'react-native';

              export default class App extends Component {
              render() {
              return (
              <View style={styles.container}>
              <Text style={styles.mainText}>This is always on top</Text>
              <View style={styles.overlay}>
              <Text>This is an overlay</Text>
              <Text>This is an overlay</Text>
              <Text>This is an overlay</Text>
              <Text>This is an overlay</Text>
              <Text>This is an overlay</Text>
              <Text>This is an overlay</Text>
              <Text>This is an overlay</Text>
              <Text>This is an overlay</Text>
              </View>
              </View>
              );
              }
              }

              const styles = StyleSheet.create({
              container: {
              flex:1,
              backgroundColor: "#00ff00",
              top: 0,
              right: 0,
              bottom: 0,
              left: 0,
              justifyContent: "center",
              alignItems: "center",
              zIndex: 1
              },
              mainText:{
              fontSize: 30,
              zIndex: 3,
              backgroundColor: '#ff0000',
              },
              overlay: {
              position: 'absolute',
              top: 0,
              right: 0,
              bottom: 0,
              left: 0,
              backgroundColor: '#fff',
              color: '#000',
              opacity: 0.5,
              justifyContent: "center",
              alignItems: "center",
              fontSize: 24,
              zIndex: 2
              }
              });


              Apply these ideas to your working app, and you can achieve what you are looking for.






              share|improve this answer
























                0












                0








                0






                You need a modal overlay. To achieve this, you must add a <View> with an opacity style over your current component. In that <View>, you must add your own custom images (with the arrows for example) and position them as you want.



                To add an opacity, you can add a style with the opacity property, like this:



                overlay: {
                opacity: 0.5,
                }


                You can set the value of the opacity as you like (between 0 and 1).



                If you want it to be as big as the screen and to be positioned over your component, you can add something like this:



                overlay: {
                position: 'absolute',
                height: '100%',
                width: '100%',
                backgroundColor: '#fff',
                opacity: 0.5,
                }


                or:



                overlay: {
                position: 'absolute',
                top: 0,
                right: 0,
                bottom: 0,
                left: 0,
                backgroundColor: '#fff',
                opacity: 0.5,
                }


                Now, for the holes in the overlay, that can be achieved by properly using the z-index property. As long as a component has a higher value of z-index, it will be on top of a component that has a lower value.



                To assign the z-index to a style, use it like this:



                onTop: {
                zIndex: 2
                }

                below: {
                zIndex: 1
                }


                Complete example



                This is a working example of a modal overlay, where the text This is always on top, is always on top:



                import React, { Component } from 'react';
                import { Image, StyleSheet, View, Text } from 'react-native';

                export default class App extends Component {
                render() {
                return (
                <View style={styles.container}>
                <Text style={styles.mainText}>This is always on top</Text>
                <View style={styles.overlay}>
                <Text>This is an overlay</Text>
                <Text>This is an overlay</Text>
                <Text>This is an overlay</Text>
                <Text>This is an overlay</Text>
                <Text>This is an overlay</Text>
                <Text>This is an overlay</Text>
                <Text>This is an overlay</Text>
                <Text>This is an overlay</Text>
                </View>
                </View>
                );
                }
                }

                const styles = StyleSheet.create({
                container: {
                flex:1,
                backgroundColor: "#00ff00",
                top: 0,
                right: 0,
                bottom: 0,
                left: 0,
                justifyContent: "center",
                alignItems: "center",
                zIndex: 1
                },
                mainText:{
                fontSize: 30,
                zIndex: 3,
                backgroundColor: '#ff0000',
                },
                overlay: {
                position: 'absolute',
                top: 0,
                right: 0,
                bottom: 0,
                left: 0,
                backgroundColor: '#fff',
                color: '#000',
                opacity: 0.5,
                justifyContent: "center",
                alignItems: "center",
                fontSize: 24,
                zIndex: 2
                }
                });


                Apply these ideas to your working app, and you can achieve what you are looking for.






                share|improve this answer












                You need a modal overlay. To achieve this, you must add a <View> with an opacity style over your current component. In that <View>, you must add your own custom images (with the arrows for example) and position them as you want.



                To add an opacity, you can add a style with the opacity property, like this:



                overlay: {
                opacity: 0.5,
                }


                You can set the value of the opacity as you like (between 0 and 1).



                If you want it to be as big as the screen and to be positioned over your component, you can add something like this:



                overlay: {
                position: 'absolute',
                height: '100%',
                width: '100%',
                backgroundColor: '#fff',
                opacity: 0.5,
                }


                or:



                overlay: {
                position: 'absolute',
                top: 0,
                right: 0,
                bottom: 0,
                left: 0,
                backgroundColor: '#fff',
                opacity: 0.5,
                }


                Now, for the holes in the overlay, that can be achieved by properly using the z-index property. As long as a component has a higher value of z-index, it will be on top of a component that has a lower value.



                To assign the z-index to a style, use it like this:



                onTop: {
                zIndex: 2
                }

                below: {
                zIndex: 1
                }


                Complete example



                This is a working example of a modal overlay, where the text This is always on top, is always on top:



                import React, { Component } from 'react';
                import { Image, StyleSheet, View, Text } from 'react-native';

                export default class App extends Component {
                render() {
                return (
                <View style={styles.container}>
                <Text style={styles.mainText}>This is always on top</Text>
                <View style={styles.overlay}>
                <Text>This is an overlay</Text>
                <Text>This is an overlay</Text>
                <Text>This is an overlay</Text>
                <Text>This is an overlay</Text>
                <Text>This is an overlay</Text>
                <Text>This is an overlay</Text>
                <Text>This is an overlay</Text>
                <Text>This is an overlay</Text>
                </View>
                </View>
                );
                }
                }

                const styles = StyleSheet.create({
                container: {
                flex:1,
                backgroundColor: "#00ff00",
                top: 0,
                right: 0,
                bottom: 0,
                left: 0,
                justifyContent: "center",
                alignItems: "center",
                zIndex: 1
                },
                mainText:{
                fontSize: 30,
                zIndex: 3,
                backgroundColor: '#ff0000',
                },
                overlay: {
                position: 'absolute',
                top: 0,
                right: 0,
                bottom: 0,
                left: 0,
                backgroundColor: '#fff',
                color: '#000',
                opacity: 0.5,
                justifyContent: "center",
                alignItems: "center",
                fontSize: 24,
                zIndex: 2
                }
                });


                Apply these ideas to your working app, and you can achieve what you are looking for.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 23 '18 at 8:30









                c-chavez

                2,13421733




                2,13421733






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441141%2freact-native-trasparent-overlay-exposing-some-component%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Berounka

                    Sphinx de Gizeh

                    Different font size/position of beamer's navigation symbols template's content depending on regular/plain...