react-native - (React Native)如何设置边距或填充或宽度或高度?
问题描述
<View style={width: 20}>Hello</View>
平台操作系统?
尺寸.get(“屏幕”)?-> 1100, 1440 ... ?
如何分隔宽度?我希望它在所有设备上看起来都一样,包括 Android 和 iPhone。
解决方案
如果要设置响应式width
,或者width
随设备而异width
,请使用Dimension
. 看看下面的代码:
import {Dimension, StyleSheet} from 'react-native`
.....
<View style={styles.container}>Hello</View>
.....
const styles = StyleSheet.create({
container:{
width: Dimension.get('screen').width, // the container will take the whole width of the device screen width
}
})
如果您得到答复,请告诉我
推荐阅读
- c++ - 在已设置的 c++ 代码(通过 makefile)Mac OS 系统中链接 Tbb 库
- angular - 如何将值从html传递给组件?
- javascript - React 最大更新深度超出错误 #185
- c# - 实体框架将字符串值转换为日期时间
- pine-script - 如何在 pine 脚本中要求用户输入
- amazon-web-services - Kafka-connect s3 源连接器配置问题
- kotlin - 意外的令牌我正在关注一个教程,我们确实使用相同的代码,但视频发布于 2018 年
- r - 将 POSIXct 日期时间转换为日期时出现意外日期 - 时区问题?
- c# - 将 Arcsin 和 Arccos 值作为常数和分数
- python - 用 Python 匹配 Arraylist 中的数组索引