-1

I'm trying to implement this answer here in NativeScript: https://stackoverflow.com/a/4737265/1261710

I don't know how to write the code with NativeScript access the 'activity root view'.

I can see in the Android docs that there is a 'getRootView()' function https://developer.android.com/reference/android/view/View.html#getRootView%28%29

and we can find views by id.

How can I implement this in NativeScript?

This is what I have tried:

android.view.getRootView(); //not there
android.getRootView(); //not there
getRootView(); // not there

android.view.findViewById(R.id.activityRoot); //not there
android.findViewById(R.id.activityRoot); //not there
findViewById(R.id.activityRoot); // not there

android.view doesn't seem to have any of the functions that I need.

user1261710
  • 2,539
  • 5
  • 41
  • 72

1 Answers1

1

You have to understand the difference between static and non-static methods. Refer marshalling docs to understand how you convert Java to JS.

import * as app from "@nativescript/core/application";

// If you haven't installed tns declarations
declare var android;

.....

app.android.foregroundActivity.findViewById(android.R.id.content);
Manoj
  • 21,753
  • 3
  • 20
  • 41