SlideShare une entreprise Scribd logo
1  sur  20
Télécharger pour lire hors ligne
Views Part 2
ImageView
ImageView
Displays an arbitrary image, such as an
icon. The ImageView class can load
images from various sources (such as
resources or content providers), takes
care of compu@ng its measurement
from the image so that it can be used in
any layout manager, and provides
various display op@ons such as scaling
and @n@ng.
ImageView
Lab
android:src
android:adjustViewBounds
android:scaleType
ImageBu1on
ImageBuEon
Displays a buEon with an image
(instead of text) that can be pressed or
clicked by the user.
ImageBu1on
Lab
android:src
android:adjustViewBounds
android:scaleType
android:background
The 9-Patch
The 9-Patch
The 9-Patch
Selector
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/btn_default_pressed”
android:state_pressed="true"/>
<item android:drawable="@drawable/btn_default_selected”
android:state_selected="true"/>
<item android:drawable="@drawable/btn_default_selected”
android:state_focused="true"/>
<item android:drawable=”@drawable/btn_default_normal"/>
</selector>
<Button android:background=“@drawable/selector_btn_default”
.../>
drawable/selector_btn_default.xml
Make it scroll!: ScrollView
<ScrollView
android:layout_width=“match_parent”
android:layout_height=“match_parent”
>
<!–- Only 1 child allowed -->
...
</ScrollView>
Use HorizontalScrollView for Horizontal Scrolling
Lab
100dp
#C62828
Padding: 16dp
Font: ?sp
#B71C1C
hEps://dl.dropboxusercontent.com
/u/19243435/bg2.jpg
hEps://dl.dropboxusercontent.com
/u/19243435/logo.jpg
ทำเลย เดี๋ยวมา!,
By con@nuing, you accept Terms of Use and Privacy Policy
Reimagined with over
30,000 new topics
Lab
Custom View
Custom View Custom ViewGroup
Custom View
Custom View
How to decide whether we
should use Custom View or not?
•  Custom Draw
•  Again … don’t fix the posi@on, do
everything rela@vely
•  Handle Input Event
Custom ViewGroup
* Use quite a lot
How to decide whether we
should use Custom View or not?
•  Group Layout for Reuse
•  Handle Input Event
•  Do something with non-standard
behavior
Custom ViewGroup
Custom View: Best Code Structure
•  init
•  initWithAErs
Lab: Test onDraw
Lab: Ini1ate with XML Live Demo
Custom View: Input Events
•  onClick
•  onLongClick
•  onTouchEvent
•  GestureDetector
Live Demo
Custom View: A1ributes
1)  Define the aEributes in attr.xml
2)  Declare xmlns and pass value to xml element
Live Demo
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name=“CustomViewStyleable">
<attr name=“isBlue" format=“boolean"/>
</declare-styleable>
</resources>
Custom View: A1ributes
3) Retrieve value through context.getTheme().obtainStyledAEributes(…)
TypedArray a = context.getTheme().obtainStyledAttributes(
attrs,
R.styleable.CustomViewStyleable,
defStyleAttr, defStyleRes);
try {
isBlue = a.getBoolean(R.styleable.CustomViewStyleable_isBlue, false);
} finally {
a.recycle();
}
Custom ViewGroup: Best Code Structure
•  initInflate
•  initInstances
•  initWithAErs
Lab: Test Infla1on
Lab: Access to UI Components
Lab: Ini1ate with XML Live Demo

Contenu connexe

Tendances

Support Design Library
Support Design LibrarySupport Design Library
Support Design LibraryTaeho Kim
 
Android ui layout
Android ui layoutAndroid ui layout
Android ui layoutKrazy Koder
 
android layouts
android layoutsandroid layouts
android layoutsDeepa Rani
 
I/O Rewind 2015 : Android Design Support Library
I/O Rewind 2015 : Android Design Support LibraryI/O Rewind 2015 : Android Design Support Library
I/O Rewind 2015 : Android Design Support LibrarySittiphol Phanvilai
 
Android Design Support Library
Android Design Support LibraryAndroid Design Support Library
Android Design Support LibraryIbnu Sina Wardy
 
Share kmu itbz_20181106
Share kmu itbz_20181106Share kmu itbz_20181106
Share kmu itbz_20181106DongHyun Gang
 
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & MenusLearn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & MenusEng Teong Cheah
 
10 asp.net session14
10 asp.net session1410 asp.net session14
10 asp.net session14Vivek chan
 
Fragment me
Fragment meFragment me
Fragment mea a
 
Invading the home screen
Invading the home screenInvading the home screen
Invading the home screenMatteo Bonifazi
 
12. Android Basic Google Map
12. Android Basic Google Map12. Android Basic Google Map
12. Android Basic Google MapOum Saokosal
 
How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in androidInnovationM
 
行動App開發管理實務 unit1
行動App開發管理實務 unit1行動App開發管理實務 unit1
行動App開發管理實務 unit1Xavier Yin
 
Android Life Cycle
Android Life CycleAndroid Life Cycle
Android Life Cyclemssaman
 

Tendances (20)

Support Design Library
Support Design LibrarySupport Design Library
Support Design Library
 
Android development session 3 - layout
Android development   session 3 - layoutAndroid development   session 3 - layout
Android development session 3 - layout
 
Android ui layout
Android ui layoutAndroid ui layout
Android ui layout
 
android layouts
android layoutsandroid layouts
android layouts
 
I/O Rewind 2015 : Android Design Support Library
I/O Rewind 2015 : Android Design Support LibraryI/O Rewind 2015 : Android Design Support Library
I/O Rewind 2015 : Android Design Support Library
 
Android Design Support Library
Android Design Support LibraryAndroid Design Support Library
Android Design Support Library
 
Advance Android Layout Walkthrough
Advance Android Layout WalkthroughAdvance Android Layout Walkthrough
Advance Android Layout Walkthrough
 
Android layouts
Android layoutsAndroid layouts
Android layouts
 
Share kmu itbz_20181106
Share kmu itbz_20181106Share kmu itbz_20181106
Share kmu itbz_20181106
 
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & MenusLearn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
 
10 asp.net session14
10 asp.net session1410 asp.net session14
10 asp.net session14
 
Fragment me
Fragment meFragment me
Fragment me
 
Android UI Patterns
Android UI PatternsAndroid UI Patterns
Android UI Patterns
 
Invading the home screen
Invading the home screenInvading the home screen
Invading the home screen
 
12. Android Basic Google Map
12. Android Basic Google Map12. Android Basic Google Map
12. Android Basic Google Map
 
How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in android
 
行動App開發管理實務 unit1
行動App開發管理實務 unit1行動App開發管理實務 unit1
行動App開發管理實務 unit1
 
Android Basics
Android BasicsAndroid Basics
Android Basics
 
Ch2 first app
Ch2 first appCh2 first app
Ch2 first app
 
Android Life Cycle
Android Life CycleAndroid Life Cycle
Android Life Cycle
 

Similaire à Chapter 10 - Views Part 2

Android Tutorials : Basic widgets
Android Tutorials : Basic widgetsAndroid Tutorials : Basic widgets
Android Tutorials : Basic widgetsPrajyot Mainkar
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1Isham Rashik
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidDenis Minja
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android AppsGil Irizarry
 
Marakana Android User Interface
Marakana Android User InterfaceMarakana Android User Interface
Marakana Android User InterfaceMarko Gargenta
 
04 user interfaces
04 user interfaces04 user interfaces
04 user interfacesC.o. Nieto
 
Android apps development
Android apps developmentAndroid apps development
Android apps developmentMonir Zzaman
 
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROID
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROIDMaterial Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROID
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROIDJordan Open Source Association
 
Mobile Application Development -Lecture 07 & 08.pdf
Mobile Application Development -Lecture 07 & 08.pdfMobile Application Development -Lecture 07 & 08.pdf
Mobile Application Development -Lecture 07 & 08.pdfAbdullahMunir32
 
WMP_MP02_revd(10092023).pptx
WMP_MP02_revd(10092023).pptxWMP_MP02_revd(10092023).pptx
WMP_MP02_revd(10092023).pptxfahmi324663
 
Jetpack Compose beginner.pdf
Jetpack Compose beginner.pdfJetpack Compose beginner.pdf
Jetpack Compose beginner.pdfAayushmaAgrawal
 
Answer1)Responsive design is the idea where all the developed pag.pdf
Answer1)Responsive design is the idea where all the developed pag.pdfAnswer1)Responsive design is the idea where all the developed pag.pdf
Answer1)Responsive design is the idea where all the developed pag.pdfankitcomputer11
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2Vivek Bhusal
 

Similaire à Chapter 10 - Views Part 2 (20)

Ap quiz app
Ap quiz appAp quiz app
Ap quiz app
 
Notes Unit4.pptx
Notes Unit4.pptxNotes Unit4.pptx
Notes Unit4.pptx
 
Android Tutorials : Basic widgets
Android Tutorials : Basic widgetsAndroid Tutorials : Basic widgets
Android Tutorials : Basic widgets
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_android
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
Marakana Android User Interface
Marakana Android User InterfaceMarakana Android User Interface
Marakana Android User Interface
 
Android ui with xml
Android ui with xmlAndroid ui with xml
Android ui with xml
 
04 user interfaces
04 user interfaces04 user interfaces
04 user interfaces
 
Android apps development
Android apps developmentAndroid apps development
Android apps development
 
Android Button
Android ButtonAndroid Button
Android Button
 
Android action bar and notifications-chapter16
Android action bar and notifications-chapter16Android action bar and notifications-chapter16
Android action bar and notifications-chapter16
 
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROID
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROIDMaterial Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROID
Material Design (The Technical Essentials) by Mohammad Aljobairi @AMMxDROID
 
Android Materials Design
Android Materials Design Android Materials Design
Android Materials Design
 
Mobile Application Development -Lecture 07 & 08.pdf
Mobile Application Development -Lecture 07 & 08.pdfMobile Application Development -Lecture 07 & 08.pdf
Mobile Application Development -Lecture 07 & 08.pdf
 
3.2 ws WMS.pdf
3.2 ws WMS.pdf3.2 ws WMS.pdf
3.2 ws WMS.pdf
 
WMP_MP02_revd(10092023).pptx
WMP_MP02_revd(10092023).pptxWMP_MP02_revd(10092023).pptx
WMP_MP02_revd(10092023).pptx
 
Jetpack Compose beginner.pdf
Jetpack Compose beginner.pdfJetpack Compose beginner.pdf
Jetpack Compose beginner.pdf
 
Answer1)Responsive design is the idea where all the developed pag.pdf
Answer1)Responsive design is the idea where all the developed pag.pdfAnswer1)Responsive design is the idea where all the developed pag.pdf
Answer1)Responsive design is the idea where all the developed pag.pdf
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2
 

Plus de Sittiphol Phanvilai

Plus de Sittiphol Phanvilai (7)

Chapter 9 - Resources System
Chapter 9 - Resources SystemChapter 9 - Resources System
Chapter 9 - Resources System
 
Chapter 6 - Views Part 1
Chapter 6 - Views Part 1Chapter 6 - Views Part 1
Chapter 6 - Views Part 1
 
Chapter 12 - Activity Intent
Chapter 12 - Activity  IntentChapter 12 - Activity  Intent
Chapter 12 - Activity Intent
 
Chapter 11 - Styling Theming
Chapter 11 - Styling ThemingChapter 11 - Styling Theming
Chapter 11 - Styling Theming
 
Chapter 4 - How to Think Like Android Developer Designer
Chapter 4  - How to Think Like Android Developer  DesignerChapter 4  - How to Think Like Android Developer  Designer
Chapter 4 - How to Think Like Android Developer Designer
 
Chapter 7 - Debugging part 1
Chapter 7 - Debugging part 1Chapter 7 - Debugging part 1
Chapter 7 - Debugging part 1
 
Chapter 8 - Dimension Units
Chapter 8 - Dimension UnitsChapter 8 - Dimension Units
Chapter 8 - Dimension Units
 

Dernier

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 

Dernier (20)

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 

Chapter 10 - Views Part 2