我如何在android中获取我的视图的中心x,y? [英] How can i get center x,y of my view in android?
本文介绍了我如何在android中获取我的视图的中心x,y?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将imageview附加到我的框架布局上.在这里,我想获取我的imageview中心坐标.我将使用相同的坐标在下一个布局中设置我的imageview.请建议我如何获取我的imageview的中心坐标.
I am attaching an imageview up on my frame layout. Here i want to get my imageview center co-ordinates. i will use that same co-ordinates to set my imageview in next layout. Please suggest me how to get the center co-ordinates of my imageview.
预先感谢
推荐答案
imageView的中心将
centre of the imageView will be
centreX=imageView.getX() + imageView.getWidth() / 2;
centreY=imageView.getY() + imageView.getHeight() / 2;
但是请确保在imageView创建之后调用它
but make sure you call it after the imageView created
这篇关于我如何在android中获取我的视图的中心x,y?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文