Changes

Jump to: navigation, search
no edit summary
Create a new project in Android Studio, entering MotionEvent into the Application name field and ebookfrenzy.com as the Company Domain setting before clicking on the Next button.
On the form factors screen, enable the Phone and Tablet option and set the minimum SDK setting to API 8: Android 2.2 (Froyo). Continue to proceed through the screens, requesting the creation of a blank activity named MotionEventActivity with a corresponding layout and menu resource files named activity_motion_eventand menu_motion_event respectively.
Click on the Finish button to initiate the project creation process.
== Designing the Activity User Interface ==
The user interface for the application’s sole activity is to consist of a RelativeLayout view containing two TextView objects. Within the Project tool window, navigate to MotionEvent -> app -> src -> main -> res -> layout and double click on the activity_motion_event.xml layout resource file to load it into the Android Studio Designer tool. One option is to design the layout illustrated in Figure 21-1 using a RelativeLayout as the root view and keeping in mind that the lower TextView component is centered horizontally within the parent view and the upper TextView is positioned a relative distance above the lower TextView. When the layout design is complete, double click on the RelativeLayout (essentially the background of the layout) and set the ID to @+id/RelativeLayout1. Repeat these steps to assign IDs @+id/textView1 and @+id/textView2 to the TextView components.
Alternatively, switch to the XML editor by selecting the Text tab at the bottom of the Designer panel and replace the current XML with the following:
[[Image:android_studio_touch_event_uiandroid_studio_touch_event_ui2.png|The user interface for an Android Studio based touch motion example app]]
Figure 21-1

Navigation menu