A (175)

(Tuis.) #1

250 CHAPTER 7: Making Apps Interactive: Intents, Event Handling, and Menus


To put this new digital image asset into place, copy the file from this book’s assets repository (ZIP)
file and into the /res/drawable-xhdpi folder, where you installed the galaxyinfoscreen.png file, using
the Windows Explorer utility. Then, right-click on the HelloUniverse project folder in the Eclipse
Package Explorer pane and select the Refresh menu option, which will allow Eclipse to “see” that
this file exists, and make it available for use, inside of the parent tag using the
android:background parameter. The XML markup looks like this:


android:background="@drawable/editgalaxyscreen"


As you can see in Figure 7-33, using the Graphical Layout Editor tab as a preview utility, the
background image looks great, but causes contrast issues with the current textColor setting, which
needs to be “flipped” from black to white, in order to be highly visible against this galaxy background
image. Thus, we will again add a textColor parameter set to #FFFFFF (white), using the familiar
android:textColor="#FFFFFF" parameter configuration.


We’ll add in an android:textColorHint parameter set to #FFFFFF to also change your hint text color
to white. We also need to add the android:textColor="#FFFFFF" to the so the user can
see text they type in!


The final XML markup for the entire eight UI elements in your final UI design should look like the
following:


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:background="@drawable/editgalaxyscreen" >
<EditText android:id="@+id/edit_colony" android:layout_margin="8dip"
android:hint="@string/hint_colony" android:textColorHint="#FFFFFF"
android:layout_alignBaseline="@+id/submit_colony" android:textColor="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<Button android:id="@+id/submit_colony" android:text="@string/ok_button"
android:layout_toRightOf="@+id/edit_colony" android:textColor="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<EditText android:id="@+id/edit_pop" android:hint="@string/hint_pop" android:textColor="#FFFFFF"
android:layout_below="@+id/edit_colony" android:layout_alignLeft="@+id/edit_colony"
android:layout_alignBaseline="@+id/submit_pop" android:textColorHint="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<Button android:id="@+id/submit_pop" android:text="@string/ok_button"
android:layout_toRightOf="@+id/edit_pop" android:textColor="#FFFFFF"
android:layout_below="@+id/submit_colony" android:layout_alignLeft="@+id/submit_colony"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<EditText android:id="@+id/edit_fleet" android:hint="@string/hint_fleet"
android:textColor="#FFFFFF"
android:layout_below="@+id/edit_pop" android:layout_alignLeft="@+id/edit_colony"
android:layout_alignBaseline="@+id/submit_fleet" android:textColorHint="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<Button android:id="@+id/submit_fleet" android:text="@string/ok_button"
android:layout_toRightOf="@+id/edit_fleet" android:textColor="#FFFFFF"
android:layout_below="@+id/submit_pop" android:layout_alignLeft="@+id/submit_colony"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<EditText android:id="@+id/edit_ships" android:hint="@string/hint_ships"
android:textColor="#FFFFFF"

Free download pdf