In
Crawl,
we used a
SeekBar
to change the value of the top
padding
of a vertical
LinearLayout
containing three
TextView
s:
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
.
MainActivity.java
activity_main.xml
strings.xml
.
\n
is the newline character,
\u0027
is the Unicode apostrophe’,
and
\u2026
is the Unicode ellipses…
AndroidManifest.xml
.
The
activity
element has the attribute
android:screenOrientation="landscape"
.
build.gradle
(Module: app)
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?