Manoj Varma
Manoj Varma

Reputation: 70

How can add imagebutton click effect?

I am working with android. I want to add onClick() effect on ImageButton preferably a color around the sides of the button after selected. I had tried with alpha effect.But It looks dark even after get back after click.

How can add ImageButton click effect?

Upvotes: 2

Views: 3640

Answers (1)

Praveen Sharma
Praveen Sharma

Reputation: 4348

you can use a selector xml like as follows :-

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/button_pressed_yellow"
          android:state_pressed="true" />
    <item android:drawable="@drawable/button_focused_orange"
          android:state_focused="true" />
    <item android:drawable="@drawable/button_normal_green" />
</selector>

and set it as a background of your Button.

Upvotes: 3

Related Questions