as

Settings
Sign out
Notifications
Alexa
亚马逊应用商店
Ring
AWS
文档
Support
Contact Us
My Cases
新手入门
设计和开发
应用发布
参考
支持
跳转到主要内容
A component’s height and width determine its size on the screen.

Fixed dimensions

The general way to set the dimensions of a component is by adding a fixed width and height to style. All dimensions in React Native are unitless, and represent density-independent pixels.
Setting dimensions this way is common for components whose size should always be fixed to a number of points and not calculated based on screen size.

Flex dimensions

Use flex in a component’s style to have the component expand and shrink dynamically based on available space. Normally you will use flex: 1, which tells a component to fill all available space, shared evenly amongst other components with the same parent. The larger the flex given, the higher the ratio of space a component will take compared to its siblings.
After you can control a component’s size, the next step is to learn how to lay it out on the screen.

Percentage dimensions

If you want to fill a certain portion of the screen, but you don’t want to use the flex layout, you can use percentage values in the component’s style. Similar to flex dimensions, percentage dimensions require parent with a defined size.

最后修改于 2026年10月26日