Crawl with ObjectAnimator

In Crawl, we used a SeekBar to change the value of the top padding of a vertical LinearLayout containing three TextViews: episode, title, and body. In this app, we use an ObjectAnimator to change the value of the top padding. We could not have changed the top padding with the ViewPropertyAnimator we saw in ViewPropertyAnimator, because a ViewPropertyAnimator can change only the translate, scale, rotation, alpha, x, y, and z properties of a View.

On Mac, type fn-control-F12 to rotate the Android emulator to landscape orientation.

A property is a field that has a setter method. For example, class MainActivity has a property named topPadding with a setter named setTopPadding. The name of the setter is the name of the property, with the first letter capitalized and prefixed with set. Close inspection reveals that class MainActivity does not actually have a field named topPadding. But we say that the class has this property anyway, because it has the setter setTopPadding.

Source code in Crawler.zip

  1. MainActivity.java
  2. activity_main.xml
  3. strings.xml. \n is the newline character, \u0027 is the Unicode apostrophe’, and \u2026 is the Unicode ellipses…
  4. AndroidManifest.xml. The activity element has the attribute android:screenOrientation="landscape".
  5. build.gradle (Module: app)

Things to try

  1. Would the design be more pure if we created a subclass of LinearLayout named CrawlableLinearLayout and let setTopPading be a method of this new class? The ObjectAnimator would then animate the topPadding property of the CrawlableLinearLayout layout. Or would this make the app unnecesssarily complicated?