android - 如何在片段而不是活动中使用 OpenGl 绘制形状
问题描述
我正在使用此说明:https ://developer.android.com/training/graphics/opengl/environment 。
但我必须使用片段而不是活动。另外我在主要片段上有一些图片,并且使用 OpenGL 我必须绘制一些形状。但是,当我启动应用程序时,它变成了空的黑屏。在某个地方我发现我可以为片段编写类似的东西,但是如果我删除这行代码,我的 xml 布局就会在应用程序上,但我需要混合片段并在这个片段上绘制形状。
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
lifecycle.addObserver(viewModel)
val rootView = inflater.inflate(R.layout.main_fragment, container, false)
val fL = rootView.findViewById<ConstraintLayout>(R.id.main)
customGLSurfaceView = CustomGLSurfaceView(requireContext())
fL.addView(customGLSurfaceView) // this line
return rootView
}
解决方案
推荐阅读
- java - java.util.ServiceConfigurationError: org.firebirdsql.gds.impl.GDSFactoryPlugin: 从 Oracle 中的 Java 存储过程读取配置文件时出错
- jquery - optgroup 与 ul 和 li 的选项
- php - PHP:无法获取文件内容
- android - 为什么当我使用targetsdkversion 30时文本没有出现在android页面中,但是当我使用targetsdkversion 28时它可以工作?
- javascript - jQuery .click() 事件不起作用。两个中的一个正在工作,另一个没有
- angular - Angular Material Dialog:如何在 afterClosed 更改后更新表格行中的数据?
- java - 如何检查隐藏元素是否显示在硒中
- maven - 无法在 SonarQube 中验证 mule 应用程序的 pom.xml
- javascript - 粘性导航栏不隐藏可滚动元素
- docker - Docker contianer 限制 CPU 资源