【问题标题】:Add a "clicked effect" in my ImageView在我的 ImageView 中添加“点击效果”
【发布时间】:2014-06-14 16:19:04
【问题描述】:

我正在为 Android 创建一个游戏,玩家可以选择从棋盘上选择一些骰子。有没有办法添加一个小视觉效果,告诉玩家他选择了哪个骰子?每个 ImageView 都有一个监听器。

骰子的Pic

【问题讨论】:

  • 是的。现在,如果您想要更多的答案,您需要告诉我们您想要展示的内容。
  • @GabeSechan 感谢您的回复。我不是在寻找复杂的东西。在所选骰子上“更亮”的照明就可以了。如果你必须推荐一些更酷的东西,我会全力以赴。

标签: android imageview visual-effects


【解决方案1】:

对于按下状态和正常状态,您将需要单独的图像。

例如

pressed_state 图像 => press_dice_img.jpg normal_state 图片 => normal_dice_img.jpg

那么你将不得不像这样在 res/drawable 文件夹中创建一个选择器文件 dice_image_view_selector.xml

<?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>

然后像这样应用到您的每个图像视图

android:background="dice_image_view_selector.xml"

【讨论】:

  • @Ali Chha thiyae? :P upvote ta kares 接受 thiyo aa :D
猜你喜欢
  • 2014-09-02
  • 2014-08-21
  • 2022-10-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多