A (175)

(Tuis.) #1
CHAPTER 13: Android Service Class and Threads: Background Processing 493


  1. Set these with “Turn Audio On” and “Turn Audio Off” data values, as
    shown in Figure 13-9. When the sight impaired access the playAudio or
    stopAudioImageView UI elements used for the audio control icons, they will
    hear these phrases from the Android voice synthesizer, informing them what
    these UI elements are for.


Figure 13-9. Create contentDescription parameter constants for the sight impaired for audio on/off icons



  1. Now that your constants are in place, open the /res/layout/
    activity_play.xml file in Eclipse and add two child widget
    tags inside the parent container tag. Configure the first
    with a playAudio ID and sound1.png image source reference and add
    some padding, say 60DIP to compress the icon down in size a bit. Use the
    marginLeft and marginTop parameters with a -50DIP value to pull the icon
    up and to the left a bit.

  2. Be sure to add the required layout_width and layout_height parameters,
    set to the value (constant) of wrap_content. Do this using the following XML
    mark-up, as shown in Figure 13-10:


<ImageView android:id="@+id/playAudio" android:src="@drawable/sound1"
android:contentDescription="@string/play_audio" android:padding="60dip"
android:layout_marginLeft="-50dip" android:layout_marginTop="-50dip"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
Free download pdf