Building Arduino Projects for the Internet of Things

(Steven Felgate) #1

CHAPTER 5 ■ IOT PATTERNS: REALTIME CLIENTS


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.intrusiondetectionsystem.MainActivity"
tools:showIn="@layout/activity_main">


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



You are going to start by first removing the existing TextView element for Hello
World shown in Listing 5-11.


Listing 5-11. 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 5-12 to content_main.xml. This
will display an intruder image.


Listing 5-12. Add an ImageView element to content_main.xml


<ImageView
android:id="@+id/intrusion_icon"
android:src="@drawable/intrusion_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 intrusion_icon , so you need to paste an
image named intrusion_icon. png to the App ➤ Res ➤ Drawable folder, as shown in
Figure  5-13. You can upload your own image or download the one in the example from
https://openclipart.org/detail/212125/walking.

Free download pdf