We saw a
SeekBar
and a
SeekBar.OnSeekBarChangeListener
here.
The
background
color
of the
RelativeLayout
is black;
the
background
color
of the three
TextView
s
is transparent.
The text is split into three
TextView
s
because the content of only the first two are centered with
android:gravity="center_horizontal"
.
To make the text justified on both sides,
we could have used a
WebView
instead of a
TextView
.
The
WebView
would display text formatted with the HTML property
text-align: justify
.
The three
TextView
s
are held in a vertical
LinearLayout
.
The
listener
moves the
TextView
s
up and down by decreasing and increasing the amount of the
LinearLayout
’s
top padding.
On Mac, type
fn-control-F12
to rotate the
Android emulator to landscape orientation.
See
Crawler
to move the crawl without a
SeekBar
.
MainActivity.java
.
linearLayout
had to be
final
to allow us to mention it in a method of the inner class.
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)
This app was inspired by the following demo.
ImageView
instead of a
Button
.
ApiDemos/src/com/example/android/apis/view/RotatingButton.java
com.example.android.apis.view.RotatingButton
is a subclass of class
Activity
.
Its
onCreate
method installs seven
SeekBar.OnSeekBarChangeListener
s
into the seven
SeekBar
s.
ApiDemos/res/layout/rotating_view.xml
LinearLayout
containing three horizontal
LinearLayout
s
and a
Button
.
The horizontal
LinearLayout
s
contain a total of seven
SeekBar
s.
ApiDemos/AndroidManifest.xml
lists class
RotatingButton
on
lines 2474–2479.
SeekBar.OnSeekBarChangeListener
is supposed to change only the top padding of the vertical
LinearLayout
.
To ensure that it does not change the other three paddings, change
linearLayout.setPadding(0, 1110 - progress, 0, 0); //left, top, right, bottomto
linearLayout.setPadding( linearLayout.getPaddingLeft(), 1110 - progress, linearLayout.getPaddingRight(), linearLayout.getPaddingBottom() );