Uncategorized

Android 1: Lesson 2

Lesson 2: Starting a New Project and Understanding XML Layout
INTRODUCTION
In this lesson you will be introduced to the folder structure of the IDE and the difference between Relative and LinearLayout. And understand how to view and change the text in XML layouts.
LESSON OBJECTIVES
By the end of this lesson, you will be able to:
1.Understanding folder structure of Eclipse 
2. Understand Relative vs Linear Layout
3. Understanding TextView and Text of the Buttons
LEARNING SEQUENCE
Required Reading
Read the following:
Introduction To Development Environment
·        Eclipse
·        Android
·        Considerations for beginning programming.
Resources
View the following: 
1.      Eclipse
2.      Android Development
Assignments 

  1. In this lesson, we’ll start with the ‘activity_main.xml’ and the basics of the folder structure
  2. Then you will want to click on the res folder which should be the last folder inside of the app
  3. After clicking on that it will expand into more folders, you’ll want to click on the layout folder which should be the sixth folder down
  4. You’ll want to click on the ‘activity_main.xml’ file located inside the layout folder, this will open up the file on the screen in the middle
  5. This file will contain the RelativeLayout and the TextView
  6. At this point you’ll want to highlight and erase everything inside the ‘activity_main.xml’ file, trust me
  7. You’ll than want to begin typing what is on screen, starting with the xml verison and then continuing downwards
  8. The LinearLayout is the home of how your app will be set up. ‘android:orientation’ tells the device that the application will be vertical, meaning it locks the accelerometer, you can change this to being horizontal for future apps
  9. ‘android:layout_width’ and ‘android:layout_height’ both control where your app is positioned. ‘Fill_parent’ describes that the app will fill the whole screen, not leaving any space on the outside of the app
  10. ‘TextView’ is the code for displaying what the text in the app shows. ‘wrap_content’ describes that the text will expand to as big as the text will be, so it leaves space for the other parts of your app
  11. ‘android:textSize’ describes how big you want the text to be. For this you can type out px for pixel or dp for density independent pixels which is a ratio for the pixels to the screen size of the phone. Allowing the text to scale up or down depending on if you have a big size phone
  12. the ‘layout_gravity’ and ‘gravity’ refer to the position of the app. The ‘layout_gravity’ tells the text where it is located on screen, it defaults to being at the top of the app, and centering it will make it in the center of the top of the app. ‘gravity’ describes that the text will be centered in the middle of it’s home in the app, which is at the top of the screen.
  13. ‘id’ describes the identification of the ‘TextView’ in the Java, allowing it to be used and changed in the Java
  14. The coding in the button portion of the app is the same as the ‘TextView’, just changing the ‘Button:Text’ and the ‘Button:id’ to distinguish which is adding and which is subracting
  15. you have just successfully created the layout of your app. Congratulations.

Leave a Reply

Your email address will not be published. Required fields are marked *