获取控件的绝对位置(包括状态栏)可以用这种方法,调用方法后,location[0]和location[1]就分别被赋值了。

        int[] location = new int[2];        view.getLocationOnScreen(location);

获取控件的相对与当前窗口的位置可以用getLocationInWindow,如果控件在dialog中,则当前窗口就是该dialog。

getLocationInWindow(location);

 

获取控件的宽高可以在view的onSizeChanged方法中获取到,也可以在onFocusChanged中得到,这个因具体需求而异。

更多相关文章

  1. Android(安卓)通过API获取数据库中的图片文件方式
  2. Android之Dialog详解(二):自定义对话框
  3. [转]Android(安卓)Launcher 分析
  4. Android(安卓)实现微信,QQ文件在其他应用打开并获取到路径
  5. delphi xe6 for android 自带控件LocationSensor优先使用GPS定位
  6. Android中获取TextView行数
  7. [Android自定义控件] Android(安卓)Scroller工具类和GestureDete
  8. layout_width和width,layout_height和height
  9. Android(安卓)Design Support Library——Navigation View

随机推荐

  1. Android电话拨打流程源码分析
  2. 21款优秀Android开源库整理推荐
  3. Android(安卓)多线程之几个基本问题
  4. Anddroid各种布局总结
  5. This Android(安卓)SDK requires Android
  6. Android群英传笔记——第九章:Android系统
  7. 请收好这一份全面 & 详细的Android学习指
  8. Android日志系统分析之日志设备驱动程序
  9. 【Android】Android之USB
  10. 创建Android库的方法及Android(安卓).aar