使用React本机以不同的屏幕尺寸缩放UI缩放
我是编程的新手,目前我正在使用React Native来制作Android应用程序。现在,我只是在自己的物理智能手机中测试我的代码。我想知道是否更容易在维度上使用“%”单元以适当地缩放不同电话尺寸的应用程序。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我是编程的新手,目前我正在使用React Native来制作Android应用程序。现在,我只是在自己的物理智能手机中测试我的代码。我想知道是否更容易在维度上使用“%”单元以适当地缩放不同电话尺寸的应用程序。
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
它取决于您的UI,就像您的UI外观一样,但是通用方法是使用React Antive默认视图属性,例如Flex,Flexbox,其根据您的UI具有不同的属性,因此它将在任何点上缩放您的UI,最高99%的设备。某些设备可能在很大程度上取决于分辨率和屏幕高度,因此您可以在宽度和高度上使用%,但仅记住特定条件而不是每个地方。
通用视图样式您可以引用此
https://reactnative.dev/docs/docs/docs/layout-props
https://reaectnative.dev/docs/image-style-props
https://reaectnative.dev/docs/shadow-props
https://reaectnative.dev/docs/view-style-style-props
您可以参考此示例,以便了解我们可以如何创建概括
https://code.tutsplus.com/tutorials/common-reacect-native-native-layouts-layouts-login-page-page-cms-cms-cms-27639
It depends upon your UI like how your UI is look like, But general approach is use react native default view property like flex, flexbox which have different property as per your UI so it will scale your UI in any point upto 99% of devices. Some of devices may very depend on resolution and screen height so for that you can use % in width and height but remember only specific condition not every where .
General View style you can refer this
https://reactnative.dev/docs/layout-props
https://reactnative.dev/docs/image-style-props
https://reactnative.dev/docs/shadow-props
https://reactnative.dev/docs/text-style-props
https://reactnative.dev/docs/view-style-props
For simple login screen UI you can refer this example so you can get idea how react native UI we can create generalize
https://code.tutsplus.com/tutorials/common-react-native-app-layouts-login-page--cms-27639