React Native获得View相对于屏幕的坐标x,y
来源:互联网 发布:写java源代码的步骤 编辑:程序博客网 时间:2024/05/16 18:43
React-Native provides a .measure(...)
method (source code) which returns the offsets and width/height of a component. Simply provide a callback function to .measure(...)
:
myComponent.measure( (fx, fy, width, height, px, py) => { console.log('Component width is: ' + width) console.log('Component height is: ' + height) console.log('X offset to frame: ' + fx) console.log('Y offset to frame: ' + fy) console.log('X offset to page: ' + px) console.log('Y offset to page: ' + py)})
Example...
The following calculates the layout of a custom component after it is rendered:
class MyComponent extends React.component { render() { return <View ref="mycomponent" /> } componentDidMount() { // Print component dimensions to console this.refs.mycomponent.measure( (fx, fy, width, height, px, py) => { console.log('Component width is: ' + width) console.log('Component height is: ' + height) console.log('X offset to frame: ' + fx) console.log('Y offset to frame: ' + fy) console.log('X offset to page: ' + px) console.log('Y offset to page: ' + py) }) }}
0 0
- React Native获得View相对于屏幕的坐标x,y
- 获取view x y 坐标
- javascript获得DOM元素X,Y坐标的函数
- wpf在获得在不同dpi下的x,y对应的x,y坐标
- Android中获得屏幕的物理像素尺寸(x * y)
- 获取view的y坐标
- android 获得当前view在屏幕的坐标
- android 获得当前view在屏幕的坐标
- cell 相对于当前屏幕坐标
- 实时显示鼠标指针相对于浏览器X轴Y轴坐标位置
- 获得鼠标在网页上的位置(x,y轴坐标)
- 怎样获得当前地图的比例尺和X、Y坐标?(SO开发)
- Unity 3d 射线(获得鼠标点击的坐标[x,y,z])
- 获得控件的屏幕坐标
- 如何得到一个控件相对于屏幕左上角的坐标
- ios 如果获取cell上控件相对于屏幕的坐标
- 【转载】c++ API 在屏幕上(或窗口中)的(x,y)坐标绘制一个点
- Android 获取View的 left、right、top、buttom、以及x、y坐标的方法
- iOS逆向工程使用LLDB的USB连接调试第三方App
- 固定在一天的某个时间刷新一次程序
- 盈利与营销部分
- 实现对称矩阵以及压缩存储
- tensorflow函数解析: tf.Session() 和tf.InteractiveSession()
- React Native获得View相对于屏幕的坐标x,y
- 欢迎使用CSDN-markdown编辑器
- QT实现对数据文本保存的办法及其操作
- JAVA实现DES的ECB/CBC的加密算法
- (转)Linux Socket过程详细解释(包括三次握手建立连接,四次握手断开连接)
- SQL查询
- ES HDFS快照坑之could not read repository data from index blob
- SpringMVC集合类型参数绑定
- 机器学习基石2-2 PLA(Perceptron Learning Algorithm)