The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.
StackView is an
ListView uses a horizontal scrolling
list as its UI metaphor,
StackView uses a stack of cards as its metaphor. Just as
ListView shows a handful of rows,
StackView shows a handful of cards. These
cards can be swiped away via a swipe towards the southwest corner of the screen.
The top card is fully visible; the edges of a few other cards can be seen but
are otherwise obscured by cards “higher in the stack”.
While certainly usable in activities and fragments,
StackView was introduced in
support of app widgets. App widgets like bookmarks, Google Books covers, and the like
StackView to show an item and allow users to navigate to the rest of the items
by flipping these virtual cards.
Generally speaking, working with
StackView is not significantly different than is
working with any other
AdapterView. You create an
Adapter defining the contents
(in this case, defining the cards), you attach the
Adapter to the
StackView somewhere on the screen.
As the cards overlap, however, transparency becomes an issue. If the top card is not
completely opaque, you will see the card beneath it “peeking through” as its contents
are blended in via the alpha channel. In some cases, this is a perfectly desirable
outcome. However, if that is not what you want, make sure that the backgrounds of
your overall container for the card’s contents (e.g., a
RelativeLayout) has an
opaque background, such as a color with
FF for the alpha value.
Also, since the objective is to have the children be visually stacked, the children
cannot be the size of the
StackView itself (e.g., the children cannot use
for a dimension).
StackView seems to work best with children that
have explicit sizes (e.g., values in
The preview of this section will not appear here for a while, due to a time machine mishap.
The preview of this section apparently resembled a Pokémon.