【发布时间】:2020-07-04 15:33:33
【问题描述】:
是否可以将 imagebutton 和可绘制文件 ( image ) 作为片段内的函数参数传递 我已经这样做了,但它显示错误
fun def(right :Drawable , x:ImageButton){
val bitmap=BitmapFactory.decodeResource(resources,R.drawable.right)
val rounded=RoundedBitmapDrawableFactory.create(resources,bitmap)
rounded.isCircular=true
val image = root.findViewById<View>(R.id.x) as ImageButton
image.setImageDrawable(rounded)
}
【问题讨论】:
-
不要使用 x.setImageDrawable 创建图像变量,因为 x 已经是 imagebutton 了?
-
x.setImageDrawable 在片段中不起作用
-
怎么样?由于图像作品和类型相同
-
显示错误信息
-
drawable怎么办,不识别“正确”参数
标签: android kotlin imagebutton