Android button setColorFilter behaviour

后端 未结 5 1398
失恋的感觉
失恋的感觉 2020-12-10 09:26

(I changed the question a bit, because the problem is a bit clearer now)

I have 4 buttons on my application, and when a user clickes certain button I change that but

5条回答
  •  悲&欢浪女
    2020-12-10 10:09

    The Drawable documentation regarding setColorFilter(ColorFilter cf) states that 'null' may be passed to remove any existing filters. So, perhaps it could be that once the TRANSPARENT filter has been applied, then your subsequent GREEN filter can't be seen? I don't know enough about .setColorFilter and PorterDuff to know for sure, but it's worth a shot. Perhaps try:

    d.setColorFilter(null); 
    d.setColorFilter(filter); 
    

    Also you could instead use this method:

    setColorFilter(int color, PorterDuff.Mode mode) 
    

提交回复
热议问题