android-studio - 屏幕截图中的黑屏
问题描述
当我截屏时。有相机预览的部分变黑。
private fun getScreenShot(view: View): Bitmap {
val returnedBitmap = Bitmap.createBitmap(view.width, view.height, Bitmap.Config.ARGB_8888)
PixelCopy.request(window, returnedBitmap, {}, Handler(Looper.getMainLooper()))
return returnedBitmap
}
activity_main.xml
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment"
android:name="com.google.ar.sceneform.ux.ArFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
解决方案
更改函数中的第一个参数
PixelCopy.request(window, returnedBitmap, {}, Handler(Looper.getMainLooper()))
至
PixelCopy.request(arFragment.sceneView, returnedBitmap, {}, Handler(Looper.getMainLooper()))
推荐阅读
- laravel - Facade 类属性 $app 是如何以及在哪里设置的?
- python - 如何从先前处于 Catch 状态的函数访问 Step Function 中的错误信息
- jquery - 样式化 MagnificPopup 图像
- ios - Xcode 不会在 Nativescript 应用程序中选择 Info.plist
- c# - EF Core '另一个实例已被跟踪'
- reactjs - 选择芯片输入不显示所选值
- excel - 如何从 VBA 项目中安全地删除所有 Option Base 1 语句
- amazon-web-services - SageMaker ClientError:调用 CreateTrainingJob 操作时发生错误 (ValidationException):无法承担角色
- java - MigLayout - componentResized() 调用次数过多
- android - 添加到购物车不会更新数量,而是再次添加产品