question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to use images in full background?

See original GitHub issue

how to set image in the background as a full image? I tried to use renderItem method for that, but it’s showing a blank screen.

------- Code ----------

import intro1 from '../../assets/images/intro1.png';
import intro2 from '../../assets/images/intro2.png';
import intro3 from '../../assets/images/intro3.png';
import intro4 from '../../assets/images/intro4.png';
import intro5 from '../../assets/images/intro5.png';
import logo from '../../assets/images/logo.png';


const styles = StyleSheet.create({
  mainContent: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'space-around',
  },
  image: {
    width: 320,
    height: 320,
  },
  text: {
    color: 'rgba(255, 255, 255, 0.8)',
    backgroundColor: 'transparent',
    textAlign: 'center',
    paddingHorizontal: 16,
  },
  title: {
    fontSize: 22,
    color: 'white',
    backgroundColor: 'transparent',
    textAlign: 'center',
    marginBottom: 16,
  },
});

const slides = [
  {
    key: 'somethun',
    title: 'Quick setup, good defaults',
    text:
      'React-native-app-intro-slider is easy to setup with a small footprint and no dependencies. And it comes with good default layouts!',
    icon: logo,
    backgroundImage: intro1,
  },
  {
    key: 'somethun1',
    title: 'Super customizable',
    text:
      'The component is also super customizable, so you can adapt it to cover your needs and wants.',
    icon: logo,
    backgroundImage: intro2,
  },
  {
    key: 'somethun2',
    title: 'No need to buy me beer',
    text: 'Usage is all free',
    icon: logo,
    backgroundImage: intro3,
  },
];

export default class App extends React.Component {
  _renderItem = props => (
    <ImageBackground
      style={[
        styles.mainContent,
        {
          width:'100%',
          height: '100%',
        },
      ]}
     source={props.backgroundImage}
    >
      <Image
        source={props.icon}
        style={styles.image}
      />
      <View>
        <Text style={styles.title}>{props.title}</Text>
        <Text style={styles.text}>{props.text}</Text>
      </View>
    </ImageBackground>
  );

  render() {
    return (
       <AppIntroSlider
           slides={slides}
           renderItem={this._renderItem}
          bottomButton />
     );
  }
}

Hmm… Render function is not empty, is not showing properly. Just updating the code of render function.

Screen Shot 2019-07-31 at 8 50 36 AM

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
Jacsecommented, Aug 1, 2019

Whoops my bad. Try this:

_renderItem = ({ item, dimensions }) => (
    <ImageBackground
      source={item.backgroundImage}
      style={[
        styles.mainContent,
        dimensions
      ]}>
      {item.title}
      {item.text}
    </ImageBackground>
  );
0reactions
creative-dev-labcommented, Aug 1, 2019

Whoops my bad. Try this:

_renderItem = ({ item, dimensions }) => (
    <ImageBackground
      source={item.backgroundImage}
      style={[
        styles.mainContent,
        dimensions
      ]}>
      {item.title}
      {item.text}
    </ImageBackground>
  );

Wow Awesome! It’s working now! Thank you so much, @Jacse Appreciated!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Perfect Full Page Background Image - CSS-Tricks
One rather simple way to handle this is to put an inline image on the page, fixed position it to the upper-left, and...
Read more >
How To Create a Full Page Image - W3Schools
Learn how to create a full page background image with CSS. Full Page Image. Learn how to create a background image that covers...
Read more >
CSS Background Image Size Tutorial – How to Code a Full ...
This tutorial will show you a simple way to code a full page background image using CSS. And you'll also learn how to...
Read more >
CSS Make Background Image Full Screen - SoftAuthor
Add an image as a background of an HTML element then resizing and positioning the background image to make it full screen.
Read more >
How to Make HTML Background Image Full Screen? - Scaler
The CSS background-size property has been used to make the HTML background image full-screen. · An element's background image is controlled by ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found