首页 > 解决方案 > 屏幕截图中的黑屏

问题描述

当我截屏时。有相机预览的部分变黑。

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"/>

标签: android-studiokotlinscreenshotaugmented-realityandroid-pixel-copy

解决方案


更改函数中的第一个参数

 PixelCopy.request(window, returnedBitmap, {}, Handler(Looper.getMainLooper()))

 PixelCopy.request(arFragment.sceneView, returnedBitmap, {}, Handler(Looper.getMainLooper()))

推荐阅读