CropImageView设置setImageBitmap后并没有出现剪裁区域
Theoneee opened this issue · comments
Theoneee commented
引入:
implementation 'com.github.pqpo:SmartCropper:v2.1.4'
配置
aaptOptions {
noCompress "tflite"
noCompress "lite"
}
初始化
SmartCropper.buildImageDetector(this)
布局
<me.pqpo.smartcropperlib.view.CropImageView
android:id="@+id/iv_crop"
app:civShowEdgeMidPoint="true"
android:background="@color/qmui_config_color_pure_black"
app:civLineColor="?attr/app_skin_primary_color"
app:civMagnifierCrossColor="@color/qmui_config_color_red"
android:layout_width="match_parent"
android:layout_height="match_parent" />
设置Bitmap
private fun setCropBitmap(path:String){
getDataBinding().ivCrop.visible()
lifecycleScope.launch {
val bitmap = withContext(Dispatchers.IO){
val options = BitmapFactory.Options()
options.inJustDecodeBounds = true
BitmapFactory.decodeFile(path, options)
options.inJustDecodeBounds = false
options.inSampleSize = calculateSampleSize(options)
BitmapFactory.decodeFile(path, options)
}
withContext(Dispatchers.Main){
getDataBinding().ivCrop.setImageBitmap(bitmap)
}
}
}
Demo显示正常