Android 在ARCore中使用ImageView显示图像
我试图在ARCore中显示2D PNG图像,但没有显示任何内容。 当我尝试使用ModelRenderable进行渲染时,3D对象的渲染效果非常好。因此,在尝试使用ViewRenderable渲染图像时,我犯了一些错误 以下是与渲染相关的代码:在下面的代码中,我得到了错误/警告,“imageView”从未被使用Android 在ARCore中使用ImageView显示图像,android,imageview,arcore,Android,Imageview,Arcore,我试图在ARCore中显示2D PNG图像,但没有显示任何内容。 当我尝试使用ModelRenderable进行渲染时,3D对象的渲染效果非常好。因此,在尝试使用ViewRenderable渲染图像时,我犯了一些错误 以下是与渲染相关的代码:在下面的代码中,我得到了错误/警告,“imageView”从未被使用 ViewRenderable.builder() .setView(context, R.layout.imgboard)
ViewRenderable.builder()
.setView(context, R.layout.imgboard)
.build()
.thenAccept(renderable -> {
ImageView imageView = (ImageView) renderable.getView();
});
以下是XML文件:
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/imageCard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/qbf"
android:adjustViewBounds="true"
android:scaleType="centerInside"/>
使用:
这与您的略有不同,因为您添加了lambda
您可能希望删除此lambda,结果是:
.thenAccept(renderable -> myRenderable = renderable);
您还需要定义您的myRenderable
(它不是ImageView
):
在.中有一个很好的例子,谢谢。但是,如果希望从URI获取图像,上述方法将不起作用,因为据我所知,无法从URI将图像加载到XML文件中。你对此有什么建议吗?嘿,我建议你问一个新问题,巴德!实际上我自己没有用过,我只是发现了输入错误:)
.thenAccept(renderable -> myRenderable = renderable);