Button

Android offers several types of Button elements, including raised buttons and flat buttons as shown in the figure below. Each button has three states: normal, disabled, and pressed.

Raised button

Use the Button element in the layout file. A raised Button is the default style.

Flat button

Flat button borderless

Implementing click listener

  1. Use the findViewById() method of the View class to find the Button in the XML layout file:

  2. Override the onClick() method:

Last updated

Was this helpful?