26 Desember 2012

Android Design with XML Basics & Testing on Android AVD - mybringback

Android Design with XML Basics & Testing on Android AVD - mybringback


n this Android Tutorial will will learn about Android Design by dipping our toes in Android XML Basics.  We will talk about the difference between fill_parent and wrap_content and also discuss the purpose of using XML string references (the @ symbol).  Lastly, I will show you have to test run your application on the Android AVD, or emulator.

Video Walkthrough



Lesson Description

When you are developing for Android, you generally work with different Activities (you can think of Activities as pages/screens/etc) and each activity will have some sort of layout. The layout is generally the GUI (Graphic User Interface) which the user interacts with.  Android design of a layout for Android can be done a few different ways: either dynamically with Java, with the graphical drag & drop method, or with Android XML.
In this tutorial, we will cover the basics of Android XML programming to define our layout.  There is a structure which is somewhat familiar to HTML, where there are different element tags within on another.  In our example we have two TextViews (simple text elements) within the layout (LinearLayout tags).  We then will see how the TextViews take up space within a Linear layout.  There is an element width and a height, and they are either defined by fill_parent (or match_parent) which will fill all the space left available to the that XML element, or wrap_content which will wrap around the XML element closely, taking up little space.  That is the Android design basics, and we will go into more parameters we can define later.
The android:text parameter of the TextView XML element will display the actual text we want to display when we run the application.  You can either reference a string references within the ProjectName/res/values/strings file with an @ reference, such as ‘android:text=”@string/hello”‘.  If you don’t like using references, nor keeping things organized, you can type out what you want without having to reference anything, such as ‘android:text=”Just Type Whatever”‘.  (Just to note, if you use this methodology, you will get a Android Warning, which is a yellow caution sign in eclipse, but it shouldn’t cause you any problems.)
Lastly, now that we know the Android design with XML basics, we will learn how to launch our Android AVD which is our emulator.  This will allow us to run our application, and test out how our Android design looks on screen.  If you would like to test the application on your real-life Android Device, make sure you check out this post to get it setup properly.

Tidak ada komentar:

Posting Komentar