O'Reilly logo

Android 3.0 Animations by Alex Shaw

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action—changing the focus of the jigsaw

At the moment, all of the pieces of our jigsaw are in focus, all of the time. If, as we brought one object to the fore, we reduced the contrast of all of the other pieces, it would enhance the visual sensation of the foreground and background.

  1. Open up RaisableImageView.java. We are going to enhance it with a new feature: focus! Shown as follows:
    public void setFocus (float focus)
    {
    if (depth>0) return;
    ShapeDrawable shadowDrawable =
    (ShapeDrawable)shadow.getDrawable();
    shadowDrawable.getPaint().setAlpha(255);
    image.setAlpha(focus);
    }
    
  2. Because setFocus plays around with the alpha values of our jigsaw pieces, we ought to make sure that we reset them the next time we want to use setDepth instead.

    At the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required