Android 屏幕(View)坐标系统
来源:互联网 发布:西安美林数据复试 编辑:程序博客网 时间:2024/06/06 08:30
首先明确一下 android中的坐标系统 :屏幕的左上角是坐标系统原点(0,0),原点向右延伸是X轴正方向,原点向下延伸是Y轴正方向。
一、View的坐标
需要注意view的坐标是相对父容器而言的,包括:getTop()、getBottom(),getLeft(),getRight()。以getTop为例,函数源代码为:
/**
* Top position of this view relative to its parent.
*相对应父控件的top位置,单位为像素,即头部到父控件的距离
* @return The top of this view, in pixels.
*/
@ViewDebug.CapturedViewProperty
public final int getTop() {
return mTop;
}
* Top position of this view relative to its parent.
*相对应父控件的top位置,单位为像素,即头部到父控件的距离
* @return The top of this view, in pixels.
*/
@ViewDebug.CapturedViewProperty
public final int getTop() {
return mTop;
}
图示1:
图示2:
1、视图左侧位置 view.getLeft()
2、视图右侧位置 view.getRight()3、视图顶部位置 view.getTop();
4、视图底部位置 view.getBottom();
5、 视图宽度 view.getWidth();
6、视图高度 view.getHeight()
二、MotionEvent类中 getRowX()和 getX()
1、event.getRowX():触摸点相对于屏幕原点的x坐标
2、event.getX(): 触摸点相对于其所在组件原点的x坐标图示
版权声明:本文为博主原创文章,未经博主允许不得转载。
0 0
- Android 屏幕(View)坐标系统
- Android 屏幕(View)坐标系统
- Android 屏幕(View)坐标系统
- Android 屏幕(View)坐标系统
- Android 屏幕(View)坐标系统
- Android 屏幕(View)坐标系统
- Android 屏幕(View)坐标系统
- Android 屏幕(View)坐标系统
- Android 屏幕(View)坐标系统
- Android 屏幕(View)坐标系统
- Android 屏幕(View)坐标系统
- Android 屏幕(View)坐标系统
- Android 关于屏幕坐标, View坐标
- android view坐标系统
- android OpenGL ES 坐标系统 和android View坐标系统
- android 获得当前view在屏幕的坐标
- android 获得当前view在屏幕的坐标
- android view获取在屏幕上的绝对坐标
- Android基础入门
- Linux C语言程序设计(五)——数组基本概念与解析
- android坐标
- openCV中waitKey函数介绍
- Palindrome Linked List
- Android 屏幕(View)坐标系统
- HMM-信道模型&前向算法
- Android开发:获取屏幕宽和高的两种方法(px、dip、分辨率之间的关系及px与dip互相转化)
- 23种设计模式之代理模式
- C&C++函数指针
- 传值 & 传地址 & 传引用 解析
- IOS GCD多线程介绍
- OpenGL蓝宝书第五章5.4Tunnuel 纹理映射和过滤:较好的可读性代码
- Android去掉标题栏和全屏