Reputation: 145
I am creating a game for Android where the player has the choice to pick some dice from the board. Is there a way to add a small visual effect that can inform the player which dice has he choose? Each ImageView have a listener already.
The Pic of the dice.
Upvotes: 1
Views: 2311
Reputation: 8856
You will need the separate images for pressed and normal states.
For example
pressed_state image => pressed_dice_img.jpg normal_state image => normal_dice_img.jpg
then you will have to make a selector file say dice_image_view_selector.xml in res/drawable folder like this
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:drawable="@drawable/pressed_dice_image" />
<item android:state_pressed="true" android:drawable="@drawable/pressed_dice_image" />
<item android:drawable="drawable/normal_dice_image" />
</selector>
then apply to your each image view like this
android:background="dice_image_view_selector.xml"
Upvotes: 2