Lecture 2 Flashcards
What is a Layout concerned with?
Organising component views in rectangular areas
Each rectangular area in a layout may be fixed or scrollable
T or F
T
Each rectangular area normally overlaps with another in a layout
T or F
F
What are the challenges of Layouts?
Must work on multiple resolutions and orientations without losing functionality
Should look good and be usable (right text size etc.)
What is the difference between screen resolution and screen density?
Resolution: Total number of pixels in a display
Density: Number of pixels that fit into an inch
What is density independence?
The uniform display of UI elements on screens with different densities
How many millimeters per inch on android?
25.4
How many points per physical inch on android?
72
Are points density independent?
Yes
What do dp and sp stand for on android?
Density independent pixels
Scale independent pixels
Are dp and sp density independent?
Yes
How many dp and sp per physical inch?
160
What are density buckets? How many are there and what are they?
Categories of densities for which images must be optimised on android
6 - Low, medium, TV, high, extra high, extra extra high
Difference between margin and padding?
Margin on outside
Padding on inside
What are fill_parent/match_parent and wrap_content layout properties?
wrap_content wants to be just big enough to enclose its contents
fill_parent and match_parent try to be the same size as the parent
What are all layouts a subclass of?
GroupView
What is LinearLayout?
all children aligned in a single direction vertically or horizontally
What is RelativeLayout?
All child views are displayed in relative positions
What is a WebView?
Displays web pages
In LinearLayout, what properties does each child view have?
Width and Height - either wrap_content or match_parent, OR specified in px or dp
Gravity - which side of the screen it is attracted to (left, centre, right)
Margin
How do you make a vertical layout work in device landscape mode?
Place layout file of the same name in the res/layout_land directory
Swap all heights for widths
Why is switching layouts at runtime problematic?
Threads
Which thread calls the onCreate of the main activity?
UI thread
What is the best way to switch content views?
AsyncTask
What two methods do you usually override in AsyncTasks?
doInBackground()
onPostExecute()
What method might you override to show progress on progress bars with AsyncTasks?
publishProgress()
What does using an AsyncTask guarantee?
All callback calls are synchronized in such a way that:
member fields set in constructor or onPreExecute can be accessed from doInBackground
member fields set in doInBackground can be accessed in onProgressUpdate and onPostExecute
How can an AsyncTask be cancelled?
Invoke cancel(boolean)
What should you do in doInBackground to ensure tasks can be cancelled?
Check isCancelled() regularly
What is the main limit of AsyncTask?
Execution is bound to calling activity so rotating screen stops it