答案 0 :(得分:0)
要查看距离视图顶部的距离,请先find the distance of view from bottom并添加视图高度
DisplayMetrics dm = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
int[] loc = new int[2];
yourView.getLocationOnScreen(loc);
int distance = dm.heightPixels - loc[1];
Int viewHeight = yourView.getHeight()
distance +=viewHeight; //distance from top of the view