Your First Kotlin Android App: An App From Scratch
Part 2: Work with an Android Activity Challenge: Access Other Views
— Android & Kotlin

Lesson Complete

Play Next Lesson

Challenge: Access Other Views

This video was last updated on Jul 5 2022

Now it’s time to try to access other views from the Activity with the knowledge you’ve gained so far.


You just learned about viewBinding and how it helps you easily access and interact with views inside your activity. Now it’s time for your first challenge in this part.

I want you to access the “Hit Me” button using the viewBinding feature like we just did earlier. Then you change the height of the button to 200.

Remember the steps: First gain access to the view using the binding instance, then you set the property you want to update in this case the height.

Alright, Goodluck with this one.

How did that go? Okay let’s get to it.

To change the height of the button, enter the following code:

binding.hitMeButton.height = 200

When you run your app, you should see the updated button height.

You can see that accessing views inside an activity really easy. This step is done and dusted. Congratulations if you’ve made it this far…

I’ll go ahead and remove all the views we accessed here since we wont be using them in our app. We just used them for demonstration so you can get a solid background of how viewBinding works.

It’s now time to use the knowledge of accessing views inside the activity to do something useful.

I’ll see you in the next episode.