Code Monkey home page Code Monkey logo

Comments (2)

jimzhao2012 avatar jimzhao2012 commented on July 17, 2024 1

因为折叠屏手机有2块屏幕,折叠起来时候显示的是附屏,展开之后显示的是全屏,折叠和展开两种场景分辨率是不同的。所以在没有折叠屏之前,RN代码中,使用获取屏幕宽度API的,

Dimension.get("window").width

是没问题的,因为这个值不会变。在折叠屏手机上,这个值会变,所以凡是使用这个API进行过比例计算、布局设置的,都可能出现问题, 所以解决方案有以下几种:

  1. Native将屏幕状态变化的事件通知JS, JS端进行页面rerender。尝试过从Native层面直接去做rerender,但是不成功,因为native的render是依靠JS端setState来触发的,native没有render所需的数据。

  2. 布局尽量使用flex:1

  3. 屏幕切换时候,native做RN页面的强制reload,这种方式可行,但是太粗暴,满足不了用户操作的连续性。

工作量来说1、2都不小的。

if u do not know Chinese, you can copy&paste to https://translate.google.com

from crn.

myprelude avatar myprelude commented on July 17, 2024

能看懂?感谢解答。。。感谢开源

from crn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.