GithubHelp home page GithubHelp logo

react-native-bgimage's Introduction

react-native-bgimage

Background images for react native

Renders your android res/drawable* images in tiling mode (repeated background) in most optimized way.

Installation

  • put your images in drawables directory: android/app/src/main/res/drawable-[m|h|x|xx|xxx]dpi
  • run: npm install --save react-native-bgimage
  • run: react-native link react-native-bgimage (or link it manually)

For React Native version < 0.47.x you must use older not compatible version use npm install [email protected] to specify it

To manual link

  • add to android/settings.gradle :
include ':react-native-bgimage'
project(':react-native-bgimage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-bgimage/android')
  • add to android/app/build.gradle in section dependencies { ... } :
compile project(':react-native-bgimage')
  • add new BgImagePackage() call in method getPackages() of android/app/src/main/java/.../MainApplication.java :
    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new BgImagePackage(), // <-- add here
          // other modules...
      );
    }

IOS

When linking consider RNTBgImage.xcodeproj is in Libraries group. All images for usage must be available in Images.xcassets catalog.

React Native usage (JS)

import BgImage from 'react-native-bgimage';

render() {
	return <BgImage drawable="testbg" style={{height:64}}>
	    <Text style={{textAlign: 'center'}}>Hello!</Text>
	</BgImage>
}

where testbg resides in android/app/src/main/res/drawable-hdpi/testbg.png

react-native-bgimage's People

Contributors

alexnd avatar daisaru11 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-native-bgimage's Issues

use images in JS assets folder

As you mentioned, images should be in the android/app/src/main/res/drawable. Is it possible to use images in assets folder? So by using image repeat property, We can add iOS support to this project. It's good idea to use same images for iOS & android.

got black if proguard = enable

enableProguardInReleaseBuilds = true
enableSeparateBuildPerCPUArchitecture = true
compileSdkVersion 23
react native 44

but it's work if I set enableProguardInReleaseBuilds to false

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.