react-native-autosize
v0.0.3
Published
react native auto convert dp and adaptive
Downloads
6
Readme
介绍
以iphone6为基准,将手机 dp(设备像素)转换为合适的dp,达到自适应
安装
npm install react-native-autosize
用法
import {StyleSheet, Text, View } from "react-native";
import React, { Component } from "react";
import autosize from "react-native-autosize";
export default class Test extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>Welcome to React Native!</Text>
<Text style={styles.instructions}>
To get started, edit index.android.js
</Text>
<Text style={styles.instructions}>
Double tap R on your keyboard to reload,{"\n"}
Shake or press menu button for dev menu
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
backgroundColor: "#F5FCFF"
},
welcome: {
fontSize: 20,
textAlign: "center",
margin: 10
},
instructions: {
fontSize: autosize(20),
textAlign: "center",
color: "#333333",
marginBottom: 5
}
});