我正在开发一个项目,该项目将在一个片段中包含 3D 模型查看器。为了做到这一点,我决定使用 sceneform。在尝试在我的选项卡片段中显示 SceneView 后,我遇到了 SceneView 的问题。
一切都是根据示例和 sceneform 文档完成的,但是sceneView
无论我分配什么颜色,都会显示黑屏。
这是场景加载器
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
vw = inflater.inflate(R.layout.fragment_open_gl, container, false);
sceneView = vw.findViewById(R.id.scene_view);
return vw;
}
和片段:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".OpenGL">
<com.google.ar.sceneform.SceneView
android:id="@+id/scene_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/Crimson"/>
</FrameLayout>
我通过添加暂停和恢复场景视图以及片段解决了这个问题:
@Override
public void onPause() {
super.onPause();
sceneView.pause();
}
@Override
public void onResume() {
super.onResume();
try {
sceneView.resume();
} catch (CameraNotAvailableException e) {
e.printStackTrace();
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)