Your First Kotlin Android App: An App From Scratch

Jul 5 2022 Kotlin 1.6, Android 12, Android Studio Bumblebee | 2021.1.1

Part 2: Work with an Android Activity

14. Challenge: Access Other Views

Episode complete

Play next episode

Next
Save for later
About this episode
See versions

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 13. Learn About Instances, Data & Functions Next episode: 15. Handle Interactions

This video Challenge: Access Other Views was last updated on Jul 5 2022

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.