Give the hex color codes for these colors:
red Ans: #ff0000 green
Ans: #008000 purple Ans:
#800080 teal
Ans: #008080 gray
Ans: #808080 silver
Ans: #c0c0c0
Trivia Question: Name three major universities whose names are colors.
Hint: one of them is Navy.
Ans: There are actually three more: Brown, Siena, Auburn
Show six ways of setting the background color in a layout. Hint: Use this chart of
hex color codes if you get stuck.
Ans: The first three ways are in the layout, the last three are in the Java activity file:
Create an Android app with a button. When the button is pressed repeatedly,
the background color of the linear layout cycles through three colors or your choice.
Ans: See the ChangeColors Example.
Using Images
Setting a background image:
Copy the background image, for example, image1.jpg into the app/res/drawable folder.
Add this attribute to the layout or widget:
android:background="@drawable/image1"
This attribute can be used to crop the background image so that it fits the layout:
android:scaleType="centerCrop"
Practice Problem 2: Add a background image to the layout in
Practice Problem 1.