Android Studio:如果您设置项目的背景色,则ListView OnClick动画将不起作用 [英] Android Studio: ListView OnClick animation doesn't work if you set background color of items

查看:183
本文介绍了Android Studio:如果您设置项目的背景色,则ListView OnClick动画将不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我已经设置了ListView内部项目的背景颜色(由ConstraintLayout中插入的几个元素组成),但是如果背景颜色至少有点透明,则单击和长按的默认动画会消失.实际上,随着透明度的降低,单击元素的效果越来越不明显.简而言之,如果颜色不透明,颜色就会隐藏动画.如何解决此问题,然后将选择动画带到前台?

In my project I've setted the background color of my items (composed of several elements inserted in a ConstraintLayout) inside a ListView but the default animation of click and long click disappears if the background color is not at least a little transparent. In fact, as transparency decreases, the effect of clicking on the elements is less and less evident. In a few words, color goes to hide the animation if isn't transparent. How to solve this problem and then bring selection animation to the foreground?

相同问题,但仍未解决: ListView项未显示点击动画

Same problem, still unresolved: ListView items not showing tap animation

推荐答案

已解决!

您只需在ListView XML标记中添加android:drawSelectorOnTop="true".这样,您可以修改和自定义列表项的背景,并同时在GUI的"z轴"顶部重新显示选择器".雨湖!

You have to simply add android:drawSelectorOnTop="true" in your ListView XML tag. In this way you can modify and customize the list item background and at the same time bring back the "selector" on top of the "z axis" of GUI. Yuhu!

这篇关于Android Studio:如果您设置项目的背景色,则ListView OnClick动画将不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆