31.3 Setting View Attributes
For the purposes of this exercise, we need the background of the ConstraintLayout view to be blue and the Button view to display text that reads “Press Me” on a yellow background. Both of these tasks can be achieved by setting attributes on the views in the Kotlin code as outlined in the following code fragment. In order to allow the text on the button to be easily translated to other languages it will be added as a String resource. Within the Project tool window, locate the app -> res -> values -> strings.xml file and modify it to add a resource value for the “Press Me” string:
<resources>
<string name="app_name">KotlinLayout</string>
<string name="press_me">Press Me</string>
</resources>
Although this is the recommended way to handle strings that are directly referenced in code, to avoid repetition...