Button in Android

  • In any software development, buttons play a vital role.
  • Buttons are the important part of any application.
  • Button is used to perform any action when we click on the button.
  • In android, when we want to perform any action on button click then we have to provide the code or functionality.
  • Each button has its own name and has the unique id which helps to identify that button when we code for particular button.
  • In android, we can use any icon as a button means we can use icons to show the caption on button.
  • Android buttons are editable; we can define style for button and can use the theme for buttons.
  • When we click on button then onClick event is fire to perform some action if we have functionality.
  • Buttons are placed in the Palette and select the Form Widget.
  • We can use button with different shapes as follows:
  • button

  • There are several properties of buttons which are shown in the diagram:
  • button

  • Using android:text attribute we can define the caption for the button.
  • Using android:textColor attribute we can provide the colored caption for the button.
  • Using android:id attribute we can provide the unique id for the button.
  • Using android:layout_width we can set the width of the button.
  • Using android:layout_height we can set the height of the button.
  • Using android:src we can provide the icon for the button.