Android Programming Tutorials

(Romina) #1
More Home Cooking

Step #2: Add the Button to the Layout


Next, we want to modify the app widget layout to incorporate this


ImageButton. Revise LunchList/res/layout/widget.xml to look like the


following:


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/widget_frame"
>
<TextView android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/next"
android:textSize="10pt"
android:textColor="#FFFFFFFF"
/>
<ImageButton android:id="@id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:src="@drawable/ff"
/>
</RelativeLayout>

At this point, if you compile and reinstall the application, then remove and


re-add the app widget from your home screen, you will see the ImageButton


appear:


326
Free download pdf