I have this code that is supposed to make an image visible, but I don't know exactly how it's supposed to be written for Kotlin.
I'm trying to use .visibility
in Kotlin, and I don't know what to give it for a value. It's based off of setVisibility()
.
Code:
fun hacerVisibleLaFoto(v: View) {
imageView.visibility = 1;
}
I put 1
in the value spot because an integer value is required there, and that's my placeholder value until I find what really goes there.
What should go after the =
sign to make the value visible?
binding.yourView.visibility = View.VISIBLE Save this answer.
In Kotlin, visibility modifiers are used to restrict the accessibility of classes, objects, interfaces, constructors, functions, properties, and their setters to a certain level. No need to set the visibility of getters because they have the same visibility as the property.
If you don't use a visibility modifier, public is used by default, which means that your declarations will be visible everywhere. If you mark a declaration as private , it will only be visible inside the file that contains the declaration. If you mark it as internal , it will be visible everywhere in the same module.
Very easy and simple
To visible a view :
ViewName.visibility = View.VISIBLE
e.g.- button.visibity = View.VISIBLE
To invisible a view :
ViewName.visibility = View.INVISIBLE
e.g.- button.visibity = View.INVISIBLE
Anything you can use like button, textview, image view etc
Hope this would work.
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