mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-14 12:11:47 +08:00
Add measureInWindow on Android
Summary:public This adds the capability to get a View in absolute position on the screen, not just relative to the RootView. This is the Android implementation Reviewed By: andreicoman11 Differential Revision: D2939170 fb-gh-sync-id: 658f1ebe6a458088f657a7469389add1a12222cd shipit-source-id: 658f1ebe6a458088f657a7469389add1a12222cd
This commit is contained in:
committed by
facebook-github-bot-4
parent
f9e81d9bcc
commit
b26f699c9a
@@ -482,6 +482,28 @@ public class NativeViewHierarchyManager {
|
||||
outputBuffer[3] = v.getHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the coordinates of a view relative to the entire phone screen (not just the RootView
|
||||
* which is what measure will return)
|
||||
*
|
||||
* @param tag - the tag for the view
|
||||
* @param outputBuffer - output buffer that contains [x,y,width,height] of the view in coordinates
|
||||
* relative to the device window
|
||||
*/
|
||||
public void measureInWindow(int tag, int[] outputBuffer) {
|
||||
UiThreadUtil.assertOnUiThread();
|
||||
View v = mTagsToViews.get(tag);
|
||||
if (v == null) {
|
||||
throw new NoSuchNativeViewException("No native view for " + tag + " currently exists");
|
||||
}
|
||||
|
||||
v.getLocationOnScreen(outputBuffer);
|
||||
|
||||
// outputBuffer[0,1] already contain what we want
|
||||
outputBuffer[2] = v.getWidth();
|
||||
outputBuffer[3] = v.getHeight();
|
||||
}
|
||||
|
||||
public int findTargetTagForTouch(int reactTag, float touchX, float touchY) {
|
||||
View view = mTagsToViews.get(reactTag);
|
||||
if (view == null) {
|
||||
|
||||
Reference in New Issue
Block a user