kotlin 协程 与 android ImageView
今天因为要给banner的图片添加圆角,使用 Bitmap 转换圆角 用协程去切换线程 在Debug中出现 ThreadException: Only the original thread that Created a view hierarchy can touch its views 不debug时正常显示 猜测原因为: 协程在debug时,当前线程被断点阻塞,自动切换到其他线程中去了 导致不是原始的view历史记录线程操作显示View 解决办法为: 在与UI界面的控件交互的代码 加上 withContext(Dispatchers.Main){ //你的 view 代码 imageView.setImageBitmap(bitmap) } 来源: https://www.cnblogs.com/caosq/p/11649746.html