在 ARCore 中使用 ImageView 显示图像
Display image using ImageView in ARCore
我正在尝试在 ARCore 中显示 2D PNG 图像,但没有显示任何内容。
当我尝试使用 ModelRenderable 进行渲染时,3D 对象的渲染效果非常好。所以在尝试使用 ViewRenderable 渲染图像时我做错了什么。
这是与渲染有关的代码:在下面的代码中,我得到了 error/warning,'imageView' 从未使用过。
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"/>
example code使用:
.thenAccept(renderable -> testViewRenderable = renderable);
这与您的略有不同,因为您添加了 lambda。
您可能想删除这个 lambda,最后是:
.thenAccept(renderable -> myRenderable = renderable);
您还需要定义 myRenderable
(不是 ImageView
):
the docs 中有一个最小示例。
我正在尝试在 ARCore 中显示 2D PNG 图像,但没有显示任何内容。 当我尝试使用 ModelRenderable 进行渲染时,3D 对象的渲染效果非常好。所以在尝试使用 ViewRenderable 渲染图像时我做错了什么。
这是与渲染有关的代码:在下面的代码中,我得到了 error/warning,'imageView' 从未使用过。
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"/>
example code使用:
.thenAccept(renderable -> testViewRenderable = renderable);
这与您的略有不同,因为您添加了 lambda。
您可能想删除这个 lambda,最后是:
.thenAccept(renderable -> myRenderable = renderable);
您还需要定义 myRenderable
(不是 ImageView
):
the docs 中有一个最小示例。