SlideShare uma empresa Scribd logo
1 de 14
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 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
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
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
Android ViewGroups
1.     LinearLayout
2.     AbsoluteLayout
3.     TableLayout
4.     RelativeLayout
5.     FrameLayout
6.      ScrollView


                     Open source Training (Android Course)
March 29, 2012
                                Adham Enaya
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
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
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
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
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
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
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
Any Question ?

                           Best, 




                   Open source Training (Android Course)
March 29, 2012
                              Adham Enaya

Mais conteúdo relacionado

Semelhante a Session 3 android UI

W1_Lec01_Lec02_Layouts.pptx
W1_Lec01_Lec02_Layouts.pptxW1_Lec01_Lec02_Layouts.pptx
W1_Lec01_Lec02_Layouts.pptxssuserc1e786
 
Designing and implementing_android_uis_for_phones_and_tablets
Designing and implementing_android_uis_for_phones_and_tabletsDesigning and implementing_android_uis_for_phones_and_tablets
Designing and implementing_android_uis_for_phones_and_tabletsTeddy Koornia
 
行動App開發管理實務unit3
行動App開發管理實務unit3行動App開發管理實務unit3
行動App開發管理實務unit3Xavier Yin
 
Marakana Android User Interface
Marakana Android User InterfaceMarakana Android User Interface
Marakana Android User InterfaceMarko Gargenta
 
WMP_MP02_revd_03(10092023).pptx
WMP_MP02_revd_03(10092023).pptxWMP_MP02_revd_03(10092023).pptx
WMP_MP02_revd_03(10092023).pptxfahmi324663
 
[PBO] Pertemuan 12 - Pemrograman Android
[PBO] Pertemuan 12 - Pemrograman Android[PBO] Pertemuan 12 - Pemrograman Android
[PBO] Pertemuan 12 - Pemrograman Androidrizki adam kurniawan
 
Android Custom Views
Android Custom ViewsAndroid Custom Views
Android Custom ViewsBabar Sanah
 
Android Training (Android UI)
Android Training (Android UI)Android Training (Android UI)
Android Training (Android UI)Khaled Anaqwa
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1Isham Rashik
 
HIT3328 - Chapter03 - Simple Interactive Apps
HIT3328 - Chapter03 - Simple Interactive AppsHIT3328 - Chapter03 - Simple Interactive Apps
HIT3328 - Chapter03 - Simple Interactive AppsYhal Htet Aung
 
Tku-行動app開發管理實務-Android應用程式開發基礎
Tku-行動app開發管理實務-Android應用程式開發基礎Tku-行動app開發管理實務-Android應用程式開發基礎
Tku-行動app開發管理實務-Android應用程式開發基礎Xavier Yin
 
mobile application development -unit-3-
mobile application development  -unit-3-mobile application development  -unit-3-
mobile application development -unit-3-TejamFandat
 

Semelhante a Session 3 android UI (20)

W1_Lec01_Lec02_Layouts.pptx
W1_Lec01_Lec02_Layouts.pptxW1_Lec01_Lec02_Layouts.pptx
W1_Lec01_Lec02_Layouts.pptx
 
Android layouts
Android layoutsAndroid layouts
Android layouts
 
Android UI Fundamentals part 1
Android UI Fundamentals part 1Android UI Fundamentals part 1
Android UI Fundamentals part 1
 
Android bootcamp-day1
Android bootcamp-day1Android bootcamp-day1
Android bootcamp-day1
 
Designing and implementing_android_uis_for_phones_and_tablets
Designing and implementing_android_uis_for_phones_and_tabletsDesigning and implementing_android_uis_for_phones_and_tablets
Designing and implementing_android_uis_for_phones_and_tablets
 
行動App開發管理實務unit3
行動App開發管理實務unit3行動App開發管理實務unit3
行動App開發管理實務unit3
 
Marakana Android User Interface
Marakana Android User InterfaceMarakana Android User Interface
Marakana Android User Interface
 
WMP_MP02_revd_03(10092023).pptx
WMP_MP02_revd_03(10092023).pptxWMP_MP02_revd_03(10092023).pptx
WMP_MP02_revd_03(10092023).pptx
 
Android Lesson 2
Android Lesson 2Android Lesson 2
Android Lesson 2
 
[PBO] Pertemuan 12 - Pemrograman Android
[PBO] Pertemuan 12 - Pemrograman Android[PBO] Pertemuan 12 - Pemrograman Android
[PBO] Pertemuan 12 - Pemrograman Android
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
 
Android Custom Views
Android Custom ViewsAndroid Custom Views
Android Custom Views
 
Android Training (Android UI)
Android Training (Android UI)Android Training (Android UI)
Android Training (Android UI)
 
01 06 - android programming basics
01  06 - android programming basics01  06 - android programming basics
01 06 - android programming basics
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1
 
HIT3328 - Chapter03 - Simple Interactive Apps
HIT3328 - Chapter03 - Simple Interactive AppsHIT3328 - Chapter03 - Simple Interactive Apps
HIT3328 - Chapter03 - Simple Interactive Apps
 
Adaptive Layout In iOS 8
Adaptive Layout In iOS 8Adaptive Layout In iOS 8
Adaptive Layout In iOS 8
 
hema ppt (2).pptx
hema ppt (2).pptxhema ppt (2).pptx
hema ppt (2).pptx
 
Tku-行動app開發管理實務-Android應用程式開發基礎
Tku-行動app開發管理實務-Android應用程式開發基礎Tku-行動app開發管理實務-Android應用程式開發基礎
Tku-行動app開發管理實務-Android應用程式開發基礎
 
mobile application development -unit-3-
mobile application development  -unit-3-mobile application development  -unit-3-
mobile application development -unit-3-
 

Último

Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 

Último (20)

Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 

Session 3 android UI

  • 1. Android Training By: Adham Enaya twitter : @adhamenaya fb.: adham.enaya a.it@hotmail.com
  • 2. Session 3: Android UI (part 1) Thursday, March 29, 2012
  • 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. 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. 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. Android ViewGroups 1. LinearLayout 2. AbsoluteLayout 3. TableLayout 4. RelativeLayout 5. FrameLayout 6. ScrollView Open source Training (Android Course) March 29, 2012 Adham Enaya
  • 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. 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. 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. 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. 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. 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. 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. Any Question ? Best,  Open source Training (Android Course) March 29, 2012 Adham Enaya