使用ViewRenderable我正在渲染布局文件。我为布局文件设置了固定的宽度和高度。
现在我正在使用ViewRenderable构建布局。
现在我需要在sunVisual节点的右侧添加另一个节点。
这段代码在 Google Pixel 2 设备上运行良好,但在 Nokia X6 设备上出现了小空间。 Google Pixel 2 截图 Nokia X6 截图 如何获取渲染视图的宽度和高度(以米为单位)?
如何根据父节点渲染视图大小将本地位置设置到父节点右侧?
请帮我解决这个问题,提前感谢。
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="500dp"
android:layout_height="50dp"
android:background="@android:color/transparent">
// Add design
</android.support.constraint.ConstraintLayout>
现在我正在使用ViewRenderable构建布局。
// Build a renderable from a 2D View.
CompletableFuture<ViewRenderable> meterOne =
ViewRenderable.builder().setView(this, R.layout.meter).build();
CompletableFuture.allOf(circle,
meterOne, meterTwo)
.handle(
(notUsed, throwable) -> {
// When you build a Renderable, Sceneform loads its resources in the background while
// returning a CompletableFuture. Call handle(), thenAccept(), or check isDone()
// before calling get().
if (throwable != null) {
DemoUtils.displayError(this, "Unable to load renderable", throwable);
return null;
}
try {
Meters.add(meterOne.get());
} catch (InterruptedException | ExecutionException ex) {
DemoUtils.displayError(this, "Unable to load renderable", ex);
}
接下来,我需要将这个ViewRenderable
对象渲染到节点上。
Node sunVisual = new Node();
sunVisual.setParent(sun);
sunVisual.setRenderable(Meters.get(0)); // View
sunVisual.setLocalScale(new Vector3(0.5f, 0.5f, 0.5f));
现在我需要在sunVisual节点的右侧添加另一个节点。
Node node = new Node();
node.setParent(sunVisual );
node.setRenderable(Meters.get(1));
node.setLocalPosition(new Vector3(2.0f, 0.0f, 0.0f));
这段代码在 Google Pixel 2 设备上运行良好,但在 Nokia X6 设备上出现了小空间。 Google Pixel 2 截图 Nokia X6 截图 如何获取渲染视图的宽度和高度(以米为单位)?
如何根据父节点渲染视图大小将本地位置设置到父节点右侧?
请帮我解决这个问题,提前感谢。