Get size of a View in React Native

前端 未结 7 1853
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 15:56

Is it possible to get the size (width and height) of a certain view? For example, I have a view showing the progress:



        
7条回答
  •  自闭症患者
    2020-11-29 16:20

    Maybe you can use measure:

    measureProgressBar() {
        this.refs.welcome.measure(this.logProgressBarLayout);
    },
    
    logProgressBarLayout(ox, oy, width, height, px, py) {
      console.log("ox: " + ox);
      console.log("oy: " + oy);
      console.log("width: " + width);
      console.log("height: " + height);
      console.log("px: " + px);
      console.log("py: " + py);
    }
    

提交回复
热议问题