Android How to Program Chapter 03 Solution Manual
Download file with the answers
Android How to Program Chapter 03 Solution Manual
1 file(s) 280.62 KB
If you are not a member register here to download this file
3 Welcome App
Obj e c t i v e s
In this chapter you’ll:
■ Learn the basics of the Eclipse
IDE for writing, running and
debugging your Android
apps.
■ Create an Eclipse project to
develop a new app.
■ Design a GUI visually
(without programming)
using the ADT (Android
Development Tools) visual
layout editor.
■ Edit the properties of GUI
components.
■ Build a simple Android app
and execute it on an Android
Virtual Device (AVD).
Self Review Exercises 2
Self Review Exercises
3.1 Fill in the blanks in each of the following statements:
a) Layout files are considered app resources and are stored in the project’s
folder. GUI layouts are placed within that folder’s layout subfolder.
b) When designing an Android GUI, you typically want it to be so that it displays
properly on various devices.
c) The Android pixel density indicates that a resource should not be scaled
regardless of screen density.
d) To change the background color to white, locate the Background property in the Properties
window and set its value to .
e) You can easily your app by creating additional XML resource files for
string resources in other languages.
f) The two measurement units for density independent pixels are and
.
g) Setting the android:layout_width and android:layout_height attributes to
indicates that the view should be just large enough to fit its content, including its padding
values that specify the spacing around the content.
h) To run an app in an Android Virtual Device (AVD), right click the app’s root node in
Eclipse in the window and select Run As > Android Application.
3.2 State whether each of the following is true or false. If false, explain why.
a) (True/False) The Eclipse IDE and the ADT (Android Development Tools) Plugin are
the most popular tools for creating and testing Android apps.
b) (True/False) A LinearLayout always arranges GUI components in a line horizontally.
c) (True/False) The layout RelativeLayout arranges components relative to one another
or relative to their parent container.
d) (True/False) Android also supports alpha (transparency) values in the range 0–100,
where 0 represents completely transparent and 100 represents completely opaque.
e) (True/False) Setting the android:layout_centerHorizontal attribute to “yes” centers
the component horizontally in the layout.
3 Chapter 3 Welcome App
Exercises
3.3 Fill in the blanks in each of the following statements:
a) The ADT’s allows you to build GUIs using drag-and-drop techniques.
b) For an Android app that you create with Eclipse, the GUI layout is stored in an XML
file called , by default.
c) The default GUI for a new Android app consists of a (layout) with a black
background.
d) The (layout) allocates space for a single component. You can add more
than one component to this layout, but each will be displayed from the layout’s upperleft
corner. The last component added will appear on top.
e) Your project’s res folder contains three subfolders for images—drawable-hdpi (high
density), drawable-mdpi (medium density) and drawable-ldpi (low density). These
folders store images with different densities.
f) If you wish to use alpha values, you can specify the color in the format ,
where the first two hexadecimal digits represent the alpha value.
g) The documentation for supporting multiple screen sizes recommends that you use density-
independent pixels for the dimensions of GUI components and other screen elements
and for font sizes.
h) One density-independent pixel is equivalent to one pixel on a screen with 160 dpi (dots
per inch). On a screen with 240 dpi, each density-independent pixel will be scaled by a
factor of .
i) On a screen with 120 dpi, each density-independent pixel is scaled by a factor of
. So, the same component that’s 100 density-independent pixels wide will
be 75 actual pixels wide.
j) Specifying the value match_parent for both the android:layout_width and android:
layout_height attributes, causes the layout to occupy the entire width and
height of layout’s element—that is, the one in which this layout is nested.
k) Setting the attribute to “center” centers the text in the TextView.
l) Android development is a combination of GUI design, and and XML coding.
3.4 State whether each of the following is true or false. If false, explain why.
a) (True/False) For images to render nicely, a high-pixel-density device needs lower-resolution
images than a low-pixel-density device.
images than a low-pixel-density device.
Exercises 4
b) (True/False) Every color can be created from a combination of red, green and blue components
called RGB values—each is an integer in the range 0–256.
called RGB values—each is an integer in the range 0–255.
c) (True/False) It’s considered a good practice to “externalize” strings, string arrays, images,
colors, font sizes, dimensions and other app resources so that you, or someone else
on your team, can manage them separately from your application’s code.
d) (True/False) You can use the Visual Layout Editor to create a working Android app
without writing any code.
3.5 (Scrapbooking App) Find four open source images of famous landmarks using websites such
as Flickr. Create an app in which you arrange the images in a collage. Add text that identifies each
landmark.
Leave a reply