Skip to content

Conversation

@ide
Copy link
Contributor

@ide ide commented Mar 26, 2015

For a very simple view I was observing that the text background was black and had to manually be set to transparent. This ensures that text nodes have a transparent background by default.

Test Plan: This example component no longer renders what looks like a black block, and instead displays legible text.

var Example = React.createClass({
  render: function() {
      return (
        <View style={styles.container}>
          <Text>hello</Text>
        </View>
      );
  },
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
  },
};

@ide ide force-pushed the clear-text-background branch 3 times, most recently from 0239b40 to 8b8e691 Compare April 6, 2015 19:40
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 7, 2015
@ide ide force-pushed the clear-text-background branch 4 times, most recently from eafb8c8 to a7315fb Compare April 15, 2015 20:59
@josebalius
Copy link

@ide While this waits to be merged, how do you set the background to transparent at the moment?

@brentvatne
Copy link
Collaborator

@josebalius - just backgroundColor: 'transparent'

@josebalius
Copy link

@brentvatne For some reason that doesn't seem to work for me :/ It works on almost everything but <Text>

@brentvatne
Copy link
Collaborator

@josebalius - strange, can you paste the code here?

@josebalius
Copy link

Sure

Stylesheet:

const PAGE_BG = "#118ac2";

let styles = StyleSheet.create({
    mainContainer: {
        flex: 1,
        flexDirection: 'column',
        justifyContent: 'center',
        backgroundColor: PAGE_BG
    },
    buttonText: {
        fontSize: 15,
        color: '#111',
        alignSelf: 'center',
        fontWeight: 'bold'
    },
    button: {
        height: 45,
        flexDirection: 'row',
        backgroundColor: 'white',
        borderColor: 'white',
        borderWidth: 1,
        borderRadius: 3,
        marginBottom: 10,
        marginTop: 20,
        alignSelf: 'stretch',
        justifyContent: 'center'
    },
    line: {height: 0, borderColor: "#FFF", borderWidth: 0.5, backgroundColor: PAGE_BG},
    input: {height: 40, color: "#FFF", marginTop: 0, backgroundColor: 'transparent'},
    inputPass: {height: 40, color: "#FFF", marginTop: 20, backgroundColor: 'transparent'},
    account: {alignSelf: 'center', color: '#FFF', backgroundColor: 'transparent'},
    create: {alignSelf: 'center', color: '#FFF', marginTop: 10, fontWeight: 'bold', backgroundColor: 'transparent'}
});

Component's render:

<View style={styles.mainContainer}>

                <Image source={require('image!login_bg')} height="670" width={Dimensions.get('window').width} style={{padding: 30, marginTop: (Dimensions.get('window').height / 2 + 100)}}>

                    <TextInput style={styles.input} placeholder="Username" placeholderTextColor="#FFFFFF" />

                    <View style={styles.line} />

                    <TextInput style={styles.inputPass} placeholder="Password" placeholderTextColor="#FFFFFF" password={true} />

                    <View style={styles.line} />

                    <TouchableHighlight onPress={(e) => this.login()} style={styles.button}>
                        <Text style={styles.buttonText}>Sign In</Text>
                    </TouchableHighlight>

                    <Text style={styles.account}>Don't have an account?</Text>

                    <Text style={styles.create}>Create one here!</Text>

                </Image>


            </View>

styles.create / styles.account are the ones not working, the other two with transparent properties are fine.

@josebalius
Copy link

@amasad Nvm I had padding on the Image element which was invalid (although it worked). Removed the padding and added an inner view layer with the padding and the text component's transparency started to work.

For a very simple view I was observing that the text background was black and had to manually be set to transparent. This ensures that text nodes have a transparent background by default.

Test Plan: This example component no longer renders what looks like a black block, and instead displays legible text.

    var Example = React.createClass({
      render: function() {
          return (
            <View style={styles.container}>
              <Text>hello</Text>
            </View>
          );
      },
    });

    var styles = StyleSheet.create({
      container: {
        flex: 1,
      },
    };
@ide ide force-pushed the clear-text-background branch from a7315fb to 9b6b1a3 Compare April 22, 2015 08:31
@ide ide closed this in 901c24e Apr 24, 2015
@ide ide deleted the clear-text-background branch April 24, 2015 21:43
mganandraj pushed a commit to mganandraj/react-native that referenced this pull request Mar 26, 2020
…IScene support from upstream. (facebook#256)

* Fix manual merge error.

* Fix missing getters from react-native-implementation.macos.js.
Cherry pick facebook#28147 into fork to Make RCTKeyWindow multi-window aware and add UIScene support to RCTRedBox.

* release _window now to ensure its UIKit ivars are dealloc'd on the main thread as the RCTRedBox can be dealloc'd on a background thread
react-one pushed a commit to react-one/react-native that referenced this pull request Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants