android - ColorDrawable不能强转BitmapDrawable???
ringa_lee
ringa_lee 2017-04-17 15:46:43
0
3
573
ringa_lee
ringa_lee

ringa_lee

reply all(3)
Peter_Zhu


The inheritance relationship is as above

Directly inherit the same parent class and cannot be forced

can be generated using the constructor of CanvasColorDrawable转成Bitmap,用 BitmapDrawable

public BitmapDrawable (Bitmap bitmap)
Ty80

Can’t.

This is not an Android problem, Java does not allow you to cast an object to an incompatible class

Peter_Zhu

Refer to Java class object type conversion knowledge, ColorDrawable and BitmapDrawable are in a horizontal relationship, and there is no possibility of forced conversion to each other. The class object conversion mechanism exists between class objects with a parent-child relationship. When forced conversion, only the parent class object can be forced to be converted into a child class object.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template