1 Star 0 Fork 0

UnPourTous/react-native-responsive-image

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

@webank/webankapp_react-native-responsive-image

本库是基于react-native-responsive-image0.1.1更新而来,后续更新将持续记录于此。

更新日志

版本 时间 内容
0.1.1 2024/12/13 初始化版本

react-native-responsive-image

you can just set one of width or height, then another will responsive by image ratio.

Installation

$ npm install @unpourtous/react-native-responsive-image --save

Usage

screen shot:

screen shot

source code:

import React from 'react'
import {
  ScrollView,
  View,
  Text,
  Image
} from 'react-native'
import ResponsiveImage from '@unpourtous/react-native-responsive-image'

export default class Demo extends React.Component {
  render () {
    return <ScrollView>
      <Text>image size: width 200, height 100</Text>
      <Text>box size: width 300, height 100</Text>
      <Text>Use ResponsiveImage: width=300*80%=240 => height=width/2=120</Text>
      <View style={{
        marginTop: 5,
        marginBottom: 20,
        width: 300,
        borderColor: 'lightgray',
        borderWidth: 10,
        justifyContent: 'center',
        alignItems: 'center'
      }}>
        <ResponsiveImage
          source={require('./test.png')}
          width={'80%'}
        />
      </View>
      <Text>Use Image: width=300*80%=240 => height=100</Text>
      <View style={{
        marginTop: 5,
        marginBottom: 20,
        width: 300,
        borderColor: 'lightgray',
        borderWidth: 10,
        justifyContent: 'center',
        alignItems: 'center'
      }}>
        <Image
          source={require('./test.png')}
          style={{
            width: '80%'
          }}
        />
      </View>
      <Text>Use ResponsiveImage: height=100*50%=50 => width=height*2=100</Text>
      <View style={{
        marginTop: 5,
        marginBottom: 20,
        width: 300,
        height: 100,
        borderColor: 'lightgray',
        borderWidth: 10,
        justifyContent: 'center',
        alignItems: 'center'
      }}>
        <ResponsiveImage
          source={require('./test.png')}
          height={'50%'}
        />
      </View>
      <Text>Use Image: height=100*50%=50 => width=200</Text>
      <View style={{
        marginTop: 5,
        marginBottom: 20,
        width: 300,
        height: 100,
        borderColor: 'lightgray',
        borderWidth: 10,
        justifyContent: 'center',
        alignItems: 'center'
      }}>
        <Image
          source={require('./test.png')}
          style={{
            height: '50%'
          }}
        />
      </View>
    </ScrollView>
  }
}

props

  • height: set image's height, number or string
  • width: set image's width, number or string
  • style: for native View component
  • other: to Image component, e.g. source

空文件

简介

react-native响应式Image组件 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/UnPourTous/react-native-responsive-image.git
git@gitee.com:UnPourTous/react-native-responsive-image.git
UnPourTous
react-native-responsive-image
react-native-responsive-image
release-v0.1.1

搜索帮助

371d5123 14472233 46e8bd33 14472233