Reputation: 1491
I have a linear layout with custome views inside it and would like them to act like a button, so highlight itself when it is pressed.
I looked into Drawable resources but cant quite understand how it is done.
Any ideas?
Upvotes: 0
Views: 745
Reputation: 1510
Create selector.xml
file in res/drawable/
folder
add next code:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/YOUR_CUSTOM_VIEW_PRESSED_BACKGROUND" android:state_pressed="true" />
<item android:drawable="@drawable/YOUR_CUSTOM_VIEW_NORMAL_BACKGROUND" />
</selector>
In your custom view add android:background="@drawable/selector"
Upvotes: 2