Load Webview using arcore/sceneform in augmented reality

I'm trying to create an app which load a webview using arcore. I've created a viewRenderable which load the layout with the webView, but when touch screen to place a webview, the webview shows a white page.

I have tried the sam xml with buttons and textview it works fine, but webview doesn't showup.

In onCreate() method:

LayoutInflater inflater = 
(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);

View view = inflater.inflate(R.layout.view_web_image, null);
WebView webView = view.findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);    
webView.getSettings().setDomStorageEnabled(true);
webView.loadUrl("https://www.google.com/");

ViewRenderable to load webview (2d view in 3d space):

ViewRenderable.builder()
    .setView(this, R.layout.view_webview)
    .setVerticalAlignment(ViewRenderable.VerticalAlignment.CENTER)
    .build()
    .thenAccept(renderable -> andyRenderable = renderable);

Anchor code:

Anchor anchor = hitResult.createAnchor();
AnchorNode anchorNode = new AnchorNode(anchor);
anchorNode.setParent(arFragment.getArSceneView().getScene());
// Create the transformable andy and add it to the anchor.
TransformableNode andy = new 
TransformableNode(arFragment.getTransformationSystem());
andy.setParent(anchorNode);
andy.setRenderable(andyRenderable);
andy.select();

XML (view_webview):

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">   

        <WebView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/webView"/>

    </RelativeLayout>

What do I need to change?

Upvotes: 2

Views: 522

Answers (0)

Related Questions