百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

react-native-responsive-image

> 编程语言
开源

适应性图像组件,用于 React Native

398 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

适应性图像组件,用于 React Native

React Native Responsive Image

Why?

React Native's Image size is rendered with the same dimensions regardless of device screen size and screen resolution. That's bad. This component scales itself seemlesly on all iOS and Android devices.

Installation

npm install react-native-responsive-image --save

Usage

`` is expecting initWidth and initHeight props.

These values are used to set image size on any device that has screen size iPhone Plus, or larger. Image is then scaled down for any smaller device.

Optional prop component is used to pass down either an Image or ImageBackground imported react-native (defaults to Image if not provided)

Example

import React, { Component } from "react";
import { AppRegistry, StyleSheet, View } from "react-native";
import ResponsiveImage from "react-native-responsive-image";

class App extends Component {
  render() {
    return (
      
        
        
        
      
    );
  }
}

AppRegistry.registerComponent("ResponsiveImageExample", () => App);

For initWidth=138 it looks like this:

Device Screen width Scale `` width
iPhone SE 320 0.77 106
iPhone X 375 0.902 117
iPhone8 Plus 414 1 138
Nokia 5 360 0.87 120
iPad (or any tablet) - 1 138

Just one image?

It sounds like you could save some loading by delivering low resolution images to screens with lower resolution. The best way is to serve just one high-resolution (retina) well compressed image. It’s surprising how well they can be compressed, and the result looks the same.

Example project

Create project

expo init ResponsiveImageExample

  • go with 'expo-template-blank'

cp ./example/App.js ./ResponsiveImageExample/App.js

cp -R ./src ./ResponsiveImageExample

cd ResponsiveImageExample

yarn start

Development

  1. Modify any files in ./src directory

  2. Propagate changes by cp -R ./src ./ResponsiveImageExample/src

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言