Snapshot view¶
viewSnapshot can convert the view into Bitmap for saving.
For inflated views¶
val bitmap = viewSnapshot(mBinding.snapshotWait)
For uninflated views¶
Note
For uninflated views, you need to provide the width and height of the view by SnapshotOption .
val view = LayoutInflater.from(this).inflate(R.layout.viewgroup_inflate, null, false)
val bitmap = viewSnapshot(view, SnapshotOption(1080, 540))