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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.