在 React Native 中獲取視圖的大小 - Get size of a View in React Native

問題:

Is it possible to get the size (width and height) of a certain view?是否可以獲取某個視圖的大小(寬度和高度)? For example, I have a view showing the progress:例如,我有一個顯示進度的視圖:

<View ref='progressBar' style={{backgroundColor:'red',flex:this.state.progress}} /> 

I need to know the actual width of the view to align other views properly.我需要知道視圖的實際寬度才能正確對齊其他視圖。 Is this possible?這可能嗎?


解決方案:

參考一: https://en.stackoom.com/question/22jDe
參考二: https://stackoom.com/question/22jDe
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章