英文:
React Native Dimensions Inconsistent Units
问题
我有一个视图宽度设置为80(使用Native Base):
<Box
maxW="80"
w="80"
rounded="lg"
overflow="hidden"
borderColor="coolGray.200"
borderWidth="1"
>
应该有足够的空间,可以在屏幕上容纳3个这些组件。当我使用 `const { width } = useWindowDimensions()` 时,我的iPad mini的宽度值返回为 `1133`。
当我检查组件时,它的宽度返回为 `328`。
在尺寸不一致的情况下,我该如何确定一行可以容纳多少个项目?例如,将80转换为328,或将1133减小到与视图的单位相同?
谢谢你的帮助!
[![点击图片描述][1]][1]
[1]: https://i.stack.imgur.com/E5iXJ.jpg
英文:
I have a view width that has been set to 80 (using Native Base):
<Box
maxW="80"
w="80"
rounded="lg"
overflow="hidden"
borderColor="coolGray.200"
borderWidth="1"
>
There should be enough for 3 of these components to fit across a screen. When I use const { width } = useWindowDimensions()
, the value for my iPad mini comes back as 1133
for the width.
When I do an inspection of the component, it comes back as being 328
in width.
How would I go about determining how many items can fit in a row when the dimensions don't seem to line up? E.g, Converting 80 to 328, or reducing 1133 to be in the same units as the view?
Thanks for your help!
答案1
得分: 0
NativeBase 单位原来是 4 dp 的值。因此,对于 w="80"
,它是 320dp。
https://github.com/GeekyAnts/NativeBase/discussions/5690
英文:
It turns out that NativeBase units are a value of 4 dp. So for w="80"
, it's 320dp.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论