How unit 3 is examined
This unit covers screen elements (views and widgets), layouts and animation; no past question has been asked on any of them, so learn the definitions and the class names.
User Interface Screen elements
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>
Definition. <mark>A View is the basic building block of an Android UI: a rectangular screen area that draws itself and handles user events, and widgets such as TextView, EditText, Button and ImageView are its subclasses.</mark>
Key points.
- TextView displays text and EditText is its editable form for user input.
- Button, CheckBox, RadioButton and Spinner take user choices, and each fires a listener such as
onClick. - ImageView shows pictures, and ListView or RecyclerView shows scrolling lists.
- Views are declared in XML with attributes like
android:id,android:text,layout_widthandlayout_height, and are fetched in code withfindViewById().
Designing User Interfaces with Layouts
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>
Definition. <mark>A layout is a ViewGroup, an invisible container that defines how its child views are arranged on the screen.</mark>
Key points.
- LinearLayout places children in one row or column, set by
android:orientation. - RelativeLayout positions children relative to each other or to the parent.
- ConstraintLayout positions views with constraints to siblings and the parent, giving a flat, efficient hierarchy.
- FrameLayout stacks children on top of each other, and TableLayout arranges them in rows and columns.
match_parentfills the parent,wrap_contentfits the content, andlayout_weightshares leftover space.
Drawing and Working with Animation
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>
Definition. <mark>Android animation changes a view's properties such as position, size, rotation or transparency over time, and drawing is done by painting shapes and bitmaps on a Canvas with a Paint object.</mark>
Key points.
- Frame (drawable) animation plays a sequence of images one after another using AnimationDrawable.
- Tween (view) animation applies translate, scale, rotate and alpha to a view, defined in XML under
res/anim. - Property animation with ValueAnimator or ObjectAnimator changes any property of any object.
- Custom drawing overrides
onDraw(Canvas)in a View, using Paint for colour and style.
Last-minute revision
- A View is the basic UI block, and a ViewGroup (layout) is a container of views.
- TextView shows text, EditText takes input, Button fires
onClick. findViewById()links an XML view to Java code.- LinearLayout is one row or column, set by orientation.
- ConstraintLayout gives a flat hierarchy using constraints.
wrap_contentfits content,match_parentfills the parent.- Frame animation plays images, tween animation transforms a view.
- Tween types are translate, scale, rotate and alpha.
- Custom drawing uses Canvas, Paint and
onDraw().
Memory hooks
- View is the brick, ViewGroup is the box of bricks.
- Tween types spell STRA: Scale, Translate, Rotate, Alpha.
- Frame animation is a flip-book, tween is a stretch of one picture.
Coverage checklist
- User Interface Screen elements: no past questions.
- Designing User Interfaces with Layouts: no past questions.
- Drawing and Working with Animation: no past questions.