The first physical click on an element, getLocationOnScreen returns 0, but the next time it clicks it returns the correct location. However, when calling gridView.performItemClick, the location always returns 0. Any idea how to solve this?
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ImageView image = (ImageView) view.findViewById(R.id.imageView); int[] location = new int[2]; image.getLocationOnScreen(location);
source share