In this blog post, I would like explain how to create a Button Pressed Effect in Android.
To do this, you need to remember three thing:
1st -normal view, 2nd -focused view and 3rd -clicked view
- Create a new layout in res\layout,(i am naming it as ‘button_style.xml’).
- Place following code into new layout i.e. in button_style.xml.
<?xml version="1.0" encoding="utf-8"?>
<item android:drawable="@drawable/button_normal" />
Use 3 different Images or Colors or Gradients to Style your Button.
3. and in your code in res/layout/main.xml or in your button’s code
4. Use this Code Snippet to Button, TextView, ImageView and EditText too.
Tips to remember:
The state_focused is not used in the Touch based device. state_focused is whenever the button is focused on using a dpad or the trackball.
Hope this helpful.
I'm currently working as Android developer at Energy Alternatives India. Interested in Application and Game development.
Latest posts by durga chiranjeevi (see all)