In Kotlin i am getting IDE error saying "Val cannot be reassigned" when i try to set width programmatically, Please see the code written in the onCreate() of Activity class,
shadowView.width = 200
Here shadowView is a View added in the layout
Simply
shadowView.layoutParams.width = 200
In order to set a view's width programmatically you should change its width in its layout params, like the example below:
val layoutParams = shadowView.layoutParams
layoutParams.width = 200
shadowView.layoutParams = layoutParams
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With