android开发用什么工具查看屏幕点击坐标
1个回答
推荐于2016-09-10
展开全部
开发自然是用代码喽。
public class AbsoluteLayout extends Activity {
private TextView tv;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView) findViewById(R.id.tv);
}
// 实现onTouchEvent方法
public boolean onTouchEvent(MotionEvent event) {
// 如果是按下操作
if (event.getAction() == MotionEvent.ACTION_DOWN) {
showXY(event.getX(), event.getY());
}
return super.onTouchEvent(event);
}
// 获取到坐标,进行判断
private void showXY(float x, float y) {
if (x > 215 && y > 215 && x < 250 && y < 250) {
tv.setText("点中了");
} else {
tv.setText("x坐标:" + x + " y坐标:" + y);
}
}
}
public class AbsoluteLayout extends Activity {
private TextView tv;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView) findViewById(R.id.tv);
}
// 实现onTouchEvent方法
public boolean onTouchEvent(MotionEvent event) {
// 如果是按下操作
if (event.getAction() == MotionEvent.ACTION_DOWN) {
showXY(event.getX(), event.getY());
}
return super.onTouchEvent(event);
}
// 获取到坐标,进行判断
private void showXY(float x, float y) {
if (x > 215 && y > 215 && x < 250 && y < 250) {
tv.setText("点中了");
} else {
tv.setText("x坐标:" + x + " y坐标:" + y);
}
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询