Subscribe / Unsubscribe Enewsletters | Login | Register

Pencil Banner

Android Studio for beginners, Part 2: Explore and code the app

Jeff Friesen | Aug. 24, 2016
Use Android Studio's project editor to write your first animated Android app

Nested inside the animation-list element is a sequence of item elements. Each item element identifies one drawable in the animation sequence via its drawable attribute. The @drawable/androidx resource reference (where x ranges from 0 through 2) identifies an image file whose name starts with android. The duration attribute identifies the number of milliseconds that must elapse before the next item element's drawable is displayed.

Save animate.xml

In the project window, right-click the drawable sub-branch of the res sub-branch. Figure 3 shows the resulting pop-up menu.

androidstudiop2 fig3

Figure 3. Add android_animate.xml as a new drawable resource

Select New from the pop-up menu, followed by File. Figure 4 shows the resulting New File dialog box.

androidstudiop2 fig4

Figure 4. Enter android_animate.xml

Type android_animate.xml into the "Enter a new file name" text field and click OK. (You'll see an android_animate.xml sub-branch under the drawable sub-branch.) Then, replace the contents of the resulting android_animate.xml tab with the code from Listing 4 and save your changes.

You'll also need to copy the android0.png, android1.png, and android2.png files (referenced in Listing 4) from the code source associated with this article to the drawable branch. Assuming you're working in Windows, select these files from Windows Explorer and paste them into this branch (right-click the branch name and select Paste).

Conclusion to Part 2

Now that you understand W2A's architecture and have learned how to code a simple animated mobile app in Android Studio, you're ready to build and run your app. Turn to Part 3 when you're ready for this final step.

 

Previous Page  1  2  3  4  5  6 

Sign up for CIO Asia eNewsletters.