1

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.

  • Yes. Now if you want more of an answer than that, you need to give us some idea of what you want to show. – Gabe Sechan Jun 14 '14 at 16:20
  • @GabeSechan Thanks for your reply. I am not searching for something complicated. A "brighter" lighting at the choosed dice will be just fine. If you have to suggest something cooler I am all ears. – TheNerdFromYesterday Jun 14 '14 at 16:24

1 Answers1

2

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"
Qadir Hussain
  • 8,721
  • 13
  • 89
  • 124