I really like the way that Gmail for Android shows the checked state for selected emails.
Why is this good? There are three visual affordances which make it very clear which emails are selected:
- the avatar is replaced by a checkmark
- the email’s background changes color
- the number of selected emails is displayed in the app bar
Why is it COOL? Look what happens when an email is selected and deselected quickly. The avatar animation is shown in reverse from the position it was at:
I have five requirements:
- Display a list with items already selected (no animation).
- Persist the selected state in the Presenter/ViewModel, not in the View.
- Animate transitions to the checked and the not-checked states.
- Report the transition to the checked/not-checked states back to the Presenter/ViewModel immediately. I don’t want to wait for the animations to complete, so other parts of the UI can update if necessary (like the app bar)
- Handle spammy clicks as gracefully as Gmail — no jumping between the checked/not-checked styles, everything should be animated
I used the
Rotate3dAnimation class from the Android samples to do the swivel itself. The main thing I changed from the sample was adding the
matrix.preScale(-1f, 1f, centerX, 0f) so that the “back” of the View wasn’t reversed.
I didn’t manage to get the 5th requirement completed — luckily, it doesn’t look too bad played at the regular animation speed:
How would you have done this? Is the reverse easier than I was thinking or are there any tricks I’m missing out on? Let me know on Twitter or below!