Adding Visual Queues for the User

Now that you have added the ToggleButton widget, you need to add a couple of visual queues for your end users. These queues are going to entail some instructional content as well as some larger text that will display the current percentage level of the brightness (between 1 and 100).

To add these queues, you must add two TextView elements in the main.xml file. The first, placed just above the ToggleButton, is as follows:

<TextView
    android:layout_width=“wrap_content”
    android:layout_height=“wrap_content”
    android:text=“ Press the toggle button to toggle the screen brightness between 20 and 100% (night and day time)”    →4
    android:layout_centerHorizontal=“true”/>                                                                            →5

The parameters in this TextView include

→4 The android:text=“…” property sets the text of the TextView.
→5 This property instructs Android to lay out the TextView in the center of the screen, horizontally. Without this instruction, this TextView, because it's included as the first view within the RelativeLayout, would anchor itself at the top-left position of the screen.

The second TextView should be placed below the ToggleButton (and before the </RelativeLayout> line), as follows:

<TextView
    android:text=“TextView”
    android:layout_width=“wrap_content”
    android:layout_height=“wrap_content”
    android:id=“@+id/currentBrightness”
    android:textSize=“55px”                                      →6
    android:layout_below=“@id/toggleButton”                      →7
    android:layout_centerHorizontal=“true”/>

The parameters in this TextView include

→6 This property instructs Android to set the font sizes for the TextView to 55px.
→7 This property instructs Android to lay out this TextView below the ToggleButton.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.66.185