Previewing the Application in the Visual Designer

That's it! You've created your layout for this application!

The full code for your layout is as follows:

<?xml version=“1.0” encoding=“utf-8”?>
<RelativeLayout xmlns:android=
    “http://schemas.android.com/apk/res/android”
    android:layout_width=“match_parent”
    android:layout_height=“match_parent”
    >
    <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)”
        android:layout_centerHorizontal=“true”/>
    <ToggleButton
        android:id=“@+id/toggleButton”
        android:layout_width=“wrap_content”
        android:layout_height=“wrap_content”
        android:layout_centerInParent=“true”
        android:textOn=“Dimmer On”
        android:textOff=“Dimmer Off”/>
    <TextView
        android:text=“TextView”
        android:layout_width=“wrap_content”
        android:layout_height=“wrap_content”
        android:id=“@+id/currentBrightness”
        android:textSize=“55px”
        android:layout_below=“@id/toggleButton”
        android:layout_centerHorizontal=“true”/>
</RelativeLayout>

Now you can see what the layout looks like in the visual designer. Click the Graphical Layout tab to view the visual designer, as shown in Figure 6-8.

Figure 6-8: The visual designer view of the layout.

image

image Depending on your layout, you may from time to time need to change the orientation of the visual designer from landscape to portrait (or back again). To do this, just click the Config drop-down list and select Portrait or Landscape as needed.

The ADT Visual Designer

The visual designer has many different layout configurations. By default, the designer is set to Android Development Phone 1 (ADP1). The ADP1 was the first development phone offered by Google. Developers could purchase an ADP1 device on which to test their apps. Since then, Google has released several other versions of the development phone. The Devices drop-down list in the visual designer shows you which ones you can work with. The configurations represent the various configurations that the device can be in. For example, the ADP1 had three states that were valid at run time:

  • Landscape, closed: Phone is in landscape mode, physical keyboard is hidden.
  • Portrait: Phone is held in portrait mode.
  • Landscape, open: Phone is in landscape mode, physical keyboard is extended.

Each device in the Devices drop-down list has its own set of configurations. You can create your own custom configurations by choosing DevicesimageCustomimageCustomimageNew.

For purposes of this book, I use the 10.1in WXGA (tablet) configuration.

..................Content has been hidden....................

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