Building Arduino Projects for the Internet of Things

(Steven Felgate) #1

CHAPTER 6 ■ IOT PATTERNS: REMOTE CONTROL


android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.codifythings.lightingcontrolsystem.MainActivity"
tools:showIn="@layout/activity_main">


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />



You can start by first removing the existing TextView element for Hello World shown
in Listing 6-4.


Listing 6-4. Remove Default Element from content_main.xml


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />


Next, add the ImageView element provided in Listing 6-5 to content_main.xml ; this
will display an image of a light bulb.


Listing 6-5. Add ImageView Element to content_main.xml


<ImageView
android:id="@+id/light_icon"
android:src="@drawable/light_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
/>


The element references an image called light_icon , so you need to provide an
image named light_icon. png in the App ➤ Res ➤ Drawable folder, as shown in
Figure  6-13. You can upload your image or download the same that has been used in the
example from https://openclipart.org/detail/220988/light-bulb-on-off.

Free download pdf