Using buttons and TextView widgets from our layout with a little help from interfaces
To follow along with this project, create a new Android Studio project, call it Kotlin Meet UI
, and choose the Empty Activity template. You can find the code and the XML layout code in the Chapter12
/Kotlin Meet UI
folder.
First, let's build a simple UI by observing the following steps:
- In the editor window of Android Studio, switch to
activity_main.xml
and make sure you are on the Design tab. - Delete the auto-generated
TextView
, the one that reads "Hello world!". - Add a TextView widget to the top-center of the layout.
- Set its text property to
0
, itsid
property totxtValue
, and itstextSize
to40sp
. Pay careful attention to the case of theid
value. It has an uppercaseV
. - Now, drag and drop six buttons on to the layout so that it looks a bit like the following diagram. The exact layout isn't important:
- When the layout is how you want it, click the Infer Constraints button to constrain all the...