I don't understand why, on a project that use Java and Kotlin, in Kotlin I have issues calling some methods of the View class.
If I try to modify the alpha of my AppCompatButton
binding.button.alpha = 0.5F
of if I directly try to modify the alpha on a newly created View
val view = View(context)
view.alpha = 1F
I have the following error
Execution failed for task ':app:compileAllDebugKotlin'. Unresolved reference: alpha
Some methods of the View class works some don't.
That's very strange, because View
class has the alpha
property and it should work.
Make sure that you have API level >= 11 and that you have a correct imports:
import android.view.View
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.