Looking at other attributes

We just saw the most important attributes we will use. It is time to see other attributes you may find handy. Other attributes are as follows:

  • src: This is the resource to use:
        android:src="@drawable/icon" 
  • background: Background for the view, hex color, or color resource is as follows:
        android:background="#ddff00" 
        android:background="@color/colorAccent" 
  • onClick: This is the method to be invoked when a user clicks on the view (usually a button)
  • visibility: This is the visibility of the view, which accepts the following parameters--gone (invisible and does not consume any layout space), invisible (invisible but consumes layout space), and visible
  • hint: This is the hint text for the view, and it accepts a string ...

Get Mastering Android Development with Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.