当前位置: 首页 > news >正文

做网站计划/阿里云官网首页

做网站计划,阿里云官网首页,全国装修公司前50强,布朗新风 中企动力提供网站建设View.getLocationInWindow(int[] location) 一个控件在其父窗口中的坐标位置 View.getLocationOnScreen(int[] location) 一个控件在其整个屏幕上的坐标位置 getLocationInWindow是以B为原点的C的坐标 getLocationOnScreen以A为原点。 下面是getLocationOnScreen示例start (Bu…
View.getLocationInWindow(int[] location)

一个控件在其父窗口中的坐标位置

View.getLocationOnScreen(int[] location)

一个控件在其整个屏幕上的坐标位置




getLocationInWindow是以B为原点的C的坐标

getLocationOnScreen以A为原点。


下面是getLocationOnScreen示例

start = (Button) findViewById(R.id.start);int []location=new int[2];start.getLocationOnScreen(location);int x=location[0];//获取当前位置的横坐标int y=location[1];//获取当前位置的纵坐标


下面是getLocationInWindow示例

start = (Button) findViewById(R.id.start);int []location=new int[2];start.getLocationInWindow(location);int x=location[0];//获取当前位置的横坐标int y=location[1];//获取当前位置的纵坐标

==================================================================================================

 附上源代码

==================================================================================================

View.getLocationInWindow(int[] location)

/*** <p>Computes the coordinates of this view in its window. The argument* must be an array of two integers. After the method returns, the array* contains the x and y location in that order.</p>** @param location an array of two integers in which to hold the coordinates*/public void getLocationInWindow(int[] location) {if (location == null || location.length < 2) {throw new IllegalArgumentException("location must be an array of two integers");}if (mAttachInfo == null) {// When the view is not attached to a window, this method does not make senselocation[0] = location[1] = 0;return;}float[] position = mAttachInfo.mTmpTransformLocation;position[0] = position[1] = 0.0f;if (!hasIdentityMatrix()) {getMatrix().mapPoints(position);}position[0] += mLeft;position[1] += mTop;ViewParent viewParent = mParent;while (viewParent instanceof View) {final View view = (View) viewParent;position[0] -= view.mScrollX;position[1] -= view.mScrollY;if (!view.hasIdentityMatrix()) {view.getMatrix().mapPoints(position);}position[0] += view.mLeft;position[1] += view.mTop;viewParent = view.mParent;}if (viewParent instanceof ViewRootImpl) {// *cough*final ViewRootImpl vr = (ViewRootImpl) viewParent;position[1] -= vr.mCurScrollY;}location[0] = (int) (position[0] + 0.5f);location[1] = (int) (position[1] + 0.5f);}
View.getLocationOnScreen(int[] location)

  /*** <p>Computes the coordinates of this view on the screen. The argument* must be an array of two integers. After the method returns, the array* contains the x and y location in that order.</p>** @param location an array of two integers in which to hold the coordinates*/public void getLocationOnScreen(int[] location) {getLocationInWindow(location);final AttachInfo info = mAttachInfo;if (info != null) {location[0] += info.mWindowLeft;location[1] += info.mWindowTop;}}

 



                            ====================================================================================

  作者:欧阳鹏  欢迎转载,与人分享是进步的源泉!

  转载请保留原文地址:http://blog.csdn.net/ouyang_peng

====================================================================================



 

转载于:https://www.cnblogs.com/ouyangpeng/p/8538053.html

http://www.jmfq.cn/news/4977937.html

相关文章:

  • 做网站论坛 前置许可/南京谷歌seo
  • 网站建设 南通/最新网络推广平台
  • 小狗做爰网站/搜索推广渠道
  • 好看的模板图片/苏州关键词优化排名推广
  • 厦门网站建设找维品/教育机构网站
  • 画画外包网站/旅游产品推广有哪些渠道
  • 滨海新区网站建设/泉州搜索推广
  • 网站制作是什么公司/友情链接交换源码
  • 淄博做淘宝网站/百度竞价推广方案范文
  • google和百度等相关网站的广告词/爱采购seo
  • 专业网站制作公司/爱站网的关键词是怎么来的
  • 研究生做网站开发/广州最新疫情最新消息
  • html做网站的代码/百度云盘官网
  • 广安seo/优化公司治理结构
  • win10 网站建设软件/2345浏览器主页网址
  • 石家庄网站制作公司/优化设计三要素
  • 用ps做招生网站/如何写软文赚钱
  • 网站建设宣传的目的/在线看crm系统
  • 郴州公司网站建设/百度官网电话客服24小时
  • 开发技术网站开发技术/seo搜索引擎优化实战
  • 贸易网站建站/什么广告推广最有效果
  • 云梦网络做网站/阜阳seo
  • 企业可以做哪些网站有哪些/创建网址快捷方式
  • 有关做美食的网站有哪些/网站seo外包公司
  • 网站建设定制公众号小程序/郑州网站制作选择乐云seo
  • 哈尔滨做网站需要多少钱/seo管家
  • 沈阳建设局网站/企业软文
  • 网站内容规划要包括什么内容/优化公司
  • 上海的外贸网站建设公司价格/seo就业
  • 如果自己建立网站/企业查询免费