Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Kotlin .visibility

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?

like image 407
StealthDroid Avatar asked Aug 07 '17 18:08

StealthDroid


People also ask

How do you show visibility in Kotlin?

binding.yourView.visibility = View.VISIBLE Save this answer.

Does Kotlin have access modifiers?

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.

How do I make a function public in Kotlin?

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.


1 Answers

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.

like image 105
Raghib Arshi Avatar answered Oct 01 '22 17:10

Raghib Arshi