I have an image button
and I want to change the color of a button when pressed. First I show it with a transparent
as a default state color as below. But it doesn't show highlighted when pressed. So I decided to use other color to highlight when pressed using state drawable. But how to keep background color through styles wise. Means by default it should be transparent and when pressed it has to show other color.
present code:
<ImageButton
android:id="@+id/imgbutton"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:src="@drawable/ic_launcher"
android:background="@android:color/transparent"
/>
Need to be coded:
<ImageButton
android:id="@+id/imgbutton"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:src="@drawable/ic_launcher"
android:background="@drawable/btnselector"
/>
So what should be the btnselector.xml here?