问题描述
当我截取屏幕截图时。有相机预览的部分变黑了。
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,Handler(Looper.getMainLooper()))