android 获取坐标
来源:互联网 发布:protobuf java any 编辑:程序博客网 时间:2024/06/02 02:06
获取坐标。。。好吧,之前在onCreate里getButtom一直都是0,纠结的很,转一遍让我解决问题的文章,谢谢原作者。
int[] location = new int[2] ;view.getLocationInWindow(location); //获取在当前窗口内的绝对坐标view.getLocationOnScreen(location);//获取在整个屏幕内的绝对坐标//location [0]--->x坐标,//location [1]--->y坐标//如果在Activity的OnCreate()事件输出那些参数,是全为0,要等UI控件都加载完了才能获取到这些。private ViewFlipper flipper;@Overridepublic void onCreate(Bundle savedInstanceState) {Log.i("demo", "onCreate");super.onCreate(savedInstanceState);setContentView(R.layout.main);flipper = (ViewFlipper)findViewById(R.id.flipper);Log.d("demo", "left:" + flipper.getLeft());Log.d("demo", "right:" + flipper.getRight());Log.d("demo", "Top:" + flipper.getTop());Log.d("demo", "Bottom:" + flipper.getBottom());Button btn = (Button)findViewById(R.id.button2);btn.setOnClickListener(new OnClickListener(){public void onClick(View v) {Log.i("demo", "onClick");Log.d("demo", "left:" + flipper.getLeft());Log.d("demo", "right:" + flipper.getRight());Log.d("demo", "Top:" + flipper.getTop());Log.d("demo", "Bottom:" + flipper.getBottom());}});}
- android 获取坐标
- android 获取坐标
- Android 获取坐标
- Android获取GPS坐标:
- Android MotionEvent 坐标获取
- Android MotionEvent 坐标获取
- android获取控件坐标
- Android MotionEvent 坐标获取
- Android获取GPS坐标
- android中获取坐标
- android中的获取坐标
- Android获取基站坐标代码
- Android获取基站坐标代码
- Android 根据坐标获取地址
- Android获取View坐标方法
- android 获取View的坐标
- android触屏获取坐标
- android获取屏幕坐标点
- 带你学习JQuery:事件属性
- Alterdialog和RadioGroup的使用
- 2011年软考系统架构设计师学习笔记第十二章
- Oracle中SQL语句解析的步骤
- AMCharts在Flex下的使用
- android 获取坐标
- PopupWindow学习总结
- extremeQoS限速
- 2011年软考系统架构设计师学习笔记第十三章
- iphone直播的实现
- Pro*c源程序中使用宿主结构保存查询结果
- Android中的XML文件的作用介绍
- C语言编译全过程
- Java Thread 多线程 线程池