Avoiding a flickering effect when switching from state_pressed to state_activated

I just recently implemented an action mode for RecyclerView- https://github.com/yccheok/RecyclerViewTutorial

I have 2 basic requirements for visual feedback.

  • When the user clicks on an element (it does not matter, he decides to click / select the element later), there should be some kind of visual feedback. This can be achieved using<item android:state_pressed="true" android:drawable="@drawable/home_menu_row_color_holo_dark" />
  • When RecyclerViewin action mode, when the user selects an item, there must be some kind of visual highlight. This can be achieved using<item android:state_activated="true" android:drawable="@drawable/orange" />

However, when making a choice in action mode, we will encounter an undesirable flickering effect. It's because.

  • When you click your finger, state_pressed = true, orange is displayed.
  • When the finger is released, state_pressed = true, white is displayed. (White color is normal)
  • The code is being executed view.setActivated(true). state_activated = true. Orange.

Since the color transition is orangewhiteorange, it causes a flickering effect, as shown in the video - https://youtu.be/9qdmQrsAcu0

I was wondering if there is a suitable technique to avoid such a flickering effect? There’s some suggestion - listview: how to handle the delay between the pressed and the activated button click, but this doesn’t work very well.

p / s If you look at the video, you will realize that when state_activated goes from true to false, the color does not seem to go right from orange to white. There seems to be some kind of animation. May I find out why this is happening?

+4

Source: https://habr.com/ru/post/1616868/


All Articles