Android Training By: Adham Enaya  twitter : @adhamenaya     fb.: adham.enaya    a.it@hotmail.com
Session 3: Android UI (part 1)     Thursday, March 29, 2012
Understanding the components of a                 screen• To define UI we use XML (easier) or Java  (dynamically-almost us...
Common Attributes for Views &                 ViewGroups•   layout_width :the width of the View or ViewGroup•   layout_hei...
Views and ViewGroups• Activity contains:      – View:             • Class name: android.view.View.             • i.e. : bu...
Android ViewGroups1.     LinearLayout2.     AbsoluteLayout3.     TableLayout4.     RelativeLayout5.     FrameLayout6.     ...
Measurements Unites• dp and dip:      – Density independent pixel.      – Recommended when specifying the dimension of vie...
LinearLayout• The LinearLayout arranges views in a single  column or a single row.      – android:orientation: vertical or...
AbsoluteLayout• enables you to specify the exact location.      – android:layout_x: x-pixel.      – android:layout_y: y-pi...
TableLayout• groups views into rows and columns.      – <TableRow> element to designate a row in the        table.      – ...
RelativeLayout• specifies how child views are positioned relative to  each other.      –   android:layout_alignParentTop: ...
Framelayout• placeholder on screen that you can use to  display a single view.• always anchored to the top left of the lay...
Scrollview• special type of FrameLayout• The ScrollView can contain only one child view  or ViewGroup.• Do not use a ListV...
Any Question ?                           Best,                    Open source Training (Android Course)March 29, 2012    ...
Upcoming SlideShare
Loading in...5
×

Session 3 android UI

1,084

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,084
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
85
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Session 3 android UI

  1. 1. Android Training By: Adham Enaya twitter : @adhamenaya fb.: adham.enaya a.it@hotmail.com
  2. 2. Session 3: Android UI (part 1) Thursday, March 29, 2012
  3. 3. Understanding the components of a screen• To define UI we use XML (easier) or Java (dynamically-almost used in games) .• UI contains widgets like buttons, text views.• XML UI is loaded during activity onCreate(), using setContentView() method.• During compilation time XML file is complied to equivalent Android GUI class. Open source Training (Android Course)March 29, 2012 Adham Enaya
  4. 4. Common Attributes for Views & ViewGroups• layout_width :the width of the View or ViewGroup• layout_height : the height of the View or ViewGroup• layout_marginTop: extra space on the top side of• layout_marginBottom : extra space on the bottom side• layout_marginLeft :extra space on the left side• layout_marginRight :extra space on the right side• layout_gravity :Specifies how child Views are positioned.• layout_x : the x-coordinate of the View or ViewGroup• layout_y : the y-coordinate of the View or ViewGroup Open source Training (Android Course)March 29, 2012 Adham Enaya
  5. 5. Views and ViewGroups• Activity contains: – View: • Class name: android.view.View. • i.e. : buttons, text boxes (EditText), labels (TextView). – ViewGroup: • Class name: android.view.ViewGroup • Special type of view. • Groups the widgets together and order them. Open source Training (Android Course)March 29, 2012 Adham Enaya
  6. 6. Android ViewGroups1. LinearLayout2. AbsoluteLayout3. TableLayout4. RelativeLayout5. FrameLayout6. ScrollView Open source Training (Android Course)March 29, 2012 Adham Enaya
  7. 7. Measurements Unites• dp and dip: – Density independent pixel. – Recommended when specifying the dimension of views in your layout. – The dimensions of view don’t change when the device resolution.• sp: – Scale independent pixel, similar to dp – Recommended when specifying font size.• pt: – Point, 1/72 of an inch• px: – The actual pixel on the screen Open source Training (Android Course)March 29, 2012 Adham Enaya
  8. 8. LinearLayout• The LinearLayout arranges views in a single column or a single row. – android:orientation: vertical or horizontal. – layout_gravity: Open source Training (Android Course)March 29, 2012 Adham Enaya
  9. 9. AbsoluteLayout• enables you to specify the exact location. – android:layout_x: x-pixel. – android:layout_y: y-pixel.• Deprecated since android 1.5, and not supported in the latest version.• Has problem when viewing the activity in high-resolution screen. Open source Training (Android Course)March 29, 2012 Adham Enaya
  10. 10. TableLayout• groups views into rows and columns. – <TableRow> element to designate a row in the table. – Each row can contain one or more views. Open source Training (Android Course)March 29, 2012 Adham Enaya
  11. 11. RelativeLayout• specifies how child views are positioned relative to each other. – android:layout_alignParentTop: true or false – android:layout_alignParentLeft: true or false – android:layout_centerHorizontal: true or false – android:layout_alignLeft – android:layout_alignRight – android:layout_below – android:layout_above – android:layout_toLeftOf – The value for each of these attributes is the ID for the view that you are referencing. Open source Training (Android Course)March 29, 2012 Adham Enaya
  12. 12. Framelayout• placeholder on screen that you can use to display a single view.• always anchored to the top left of the layout.• You can add multiple views to a FrameLayout, but each will be stacked on top of the previous one. This is useful in cases where you want to animate series of images, with only one visible at a time. Open source Training (Android Course)March 29, 2012 Adham Enaya
  13. 13. Scrollview• special type of FrameLayout• The ScrollView can contain only one child view or ViewGroup.• Do not use a ListView together with the ScrollView. (ListView is optimized for dealing with large lists). Open source Training (Android Course)March 29, 2012 Adham Enaya
  14. 14. Any Question ? Best,  Open source Training (Android Course)March 29, 2012 Adham Enaya
  1. ¿Le ha llamado la atención una diapositiva en particular?

    Recortar diapositivas es una manera útil de recopilar información importante para consultarla más tarde.

×