Android??????????????????μ????????
???????????? ???????[ 2012/10/26 10:19:07 ] ????????
???????????е?????λ??????????????????п????????????Σ??????????????????????????λ???????
?????????????????????????????????????????dpi?????С???????????????????????????????????????
1: // ???????????????View?????
2: public void clickOnScreen(View view?? boolean longClick?? int time) {
3: if(view == null)
4: Assert.assertTrue("View is null and can therefore not be clicked!"?? false);
5: int[] xy = new int[2];
6:
7: // ??????????????λ?? – ?????dpi?????С?????????λ??????????λ??
8: view.getLocationOnScreen(xy);
9:
10: // ?????????С??????????????????е?λ??
11: final int top = view.getTop();
12: final int viewWidth = view.getWidth();
13: final int viewHeight = view.getHeight();
14: float x = xy[0] + (viewWidth / 2.0f);
15: float y = xy[1] + (viewHeight / 2.0f);
16:
17: // ?????????????????????x?? y????????????????????
18: Activity activity = activityUtils.getCurrentActivity();
19: DisplayMetrics rdm = activity.getResources().getDisplayMetrics();
20: DisplayMetrics wdm = new DisplayMetrics();
21: activity.getWindowManager().getDefaultDisplay().getMetrics(wdm);
22: x *= wdm.scaledDensity / rdm.scaledDensity;
23: y *= wdm.scaledDensity / rdm.scaledDensity;
24:
25: // ???????Android??????
26: if (longClick)
27: clickLongOnScreen(x?? y?? time);
28: else
29: clickOnScreen(x?? y);
30: }
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11