我有这个样式表,当我把高度设置为百分比时,我试图使它的宽度等于高度.我犯了以下错误,但没有成功:

art: {
    height: "70%",
    width: styles.podcastArt.height,
    marginRight:10,
    marginTop:10,
    marginBottom:10,
},

任何 idea 或方向都会有帮助.谢谢

推荐答案

设定aspectRatio: 1

art: {
    height: "70%",
    aspectRatio: 1,
    marginRight:10,
    marginTop:10,
    marginBottom:10,
},

React-native相关问答推荐

类似Snapchat的Reaction Native筛选器

react-redux connect 和 redux 数据的组件生命周期顺序

react-native-snap-carousel 无法正确渲染

为应用创建单个 MobX store 的最佳方式是什么?

在根项目ReactNativeStarter中找不到任务installRelease

react native 中 componentDidMount 和 componentDidUpdate 有什么区别

打包程序无法启动

没有找到 `React-fishhook` 的 podspec

试图注册两个具有相同名称 ProgressBarAndroid 的视图

当我导航到react-native 的新页面时,如何强制卸载组件?

如何删除不需要的expo 模块

在 Docker 中使用 Fastlane 构建 iOS 应用

你如何从 React Native 的 EventEmitter 实例中移除一个监听器?

如何使 React Native Animated.View 可点击?

Rich ReactNative TextInput

如何将 BuildConfig 值传递给依赖模块?

horizontal水平 FlatList 前后的间距

在 `../node_modules/react-native/React` 中找不到 `React-Core` 的 podspec

如何为 TouchableOpacity 组件创建禁用样式?

如何在 react-native 中为带有图标的按钮建模