private int []location; @Override protected void initView() { location = new int[2]; left.setText(getIntent().getStringExtra("type_left")); right.setText(getIntent().getStringExtra("type_right")); final View view = findViewById(R.id.me_to_left); view.post(new Runnable(){ public void run(){ left.getLocationInWindow(location); System.out.println(left.getWidth()+"@@"+location[0]+"@@"+location[1]+"@@"+ BaseTools.getWindowWidth(MeTo_ToMeActivity.this)); } }); addList(); lision();}
getLocationOnScreen
,计算该视图在全局坐标系中的x,y值,(注意这个值是要从屏幕顶端算起,也就是索包括了通知栏的高度)//获取在当前屏幕内的绝对坐标
getLocationInWindow,计算该视图在它所在的widnow的坐标x,y值,//获取在整个窗口内的绝对坐标 (不是很理解= =、)
getLeft, getTop, getBottom, getRight, 这一组是获取相对在它父亲里的坐标
控件位置
最新推荐文章于 2021-09-04 16:06:59 发布