SlideShare a Scribd company logo
1 of 35
Layout
Android Training
By Khaled Anaqwa
As if a device can function if it
has no style. As if a device can
be called stylish that does not
function superbly.... Yes,
beauty matters. Boy, does it
matter. It is not surface, it is not
an extra, it is the thing itself.
—STEPHEN FRY, THE GUARDIAN
(OCTOBER 27, 2007)
User Interface







All user interface elements in an Android app
are built using View and ViewGroup objects.
A View is an object that draws something on
the screen that the user can interact with.
A ViewGroup is an object that holds other
View (and ViewGroup) objects in order to
define the layout of the interface.
The user interface for each component of
your app is defined using a hierarchy of View
and ViewGroup objects.
 This

hierarchy tree can be as simple or
complex as you need it to be.
Layouts


A layout defines the visual structure for a user
interface, such as the UI for an activity or app
widget.


You can declare a layout in two ways:
Declare UI elements in XML.
 Instantiate layout elements at runtime





The Android framework gives you the flexibility
to use either or both .
The advantage to declaring your UI in XML is
that it enables you to better separate the
presentation from the code that controls its
behavior.
Using Eclipse to Design Layout
Resources
 Use

the Outline pane to Add and Remove
controls to your layout resource.
 Select a specific control (either in the
Preview or the Outline) and use the
Property pane to adjust a specific
control’s attributes.
 Use the XML tab to edit the XML definition
directly.
Write the XML
 Each

layout file must contain exactly one
root element.
 XML vocabulary for declaring UI elements
closely follows the structure and naming
of the classes and methods.
 For example, the EditText element has a
text attribute that corresponds to
EditText.setText().
Attributes Overview






Every View and ViewGroup object supports
their own variety of XML attributes.
Some attributes are specific (e.g. TextView
supports the textSize attribute)
These attributes are also inherited by any
View objects that may extend this class.
Some are common to all View
objects, because they are inherited from the
root View class (like the id attribute).
Attributes Examples


ID (Any View object may have an integer ID
associated with it, to uniquely identify the
View within the tree.)







android:id="@+id/my_button”
The at-symbol (@) at the beginning of the string
indicates that the XML parser should parse and
expand the rest of the ID string and identify it as an
ID resource.
The plus-symbol (+) means that this is a new
resource name that must be created and added to
our resources (in the R.java file)
android:id="@android:id/empty” (from android.R)
Demo
 Create

View in xml
 Create the same view in code
Question?

If I Instantiate view at runtime how I can
assign ID to it ?
Attributes Examples


Layout Parameters (XML layout attributes
named layout_something )



for the View that are appropriate for the
ViewGroup in which it resides.
All view groups include a width and height
(layout_width and layout_height), and each
view is required to define them.

wrap_content tells your view to size itself to the
dimensions required by its content
 fill_parent (renamed match_parent in API Level
8) tells your view to become as big as its parent
view group will allow.



Every LayoutParams subclass has its own
syntax for setting values. Each child element
must define LayoutParams that are
appropriate for its parent, though it may also
define different LayoutParams for its own
children.
Note (not Galaxy Note)
 specifying

a layout width and height using
absolute units such as pixels is not
recommended. Instead, using relative
measurements such as densityindependent pixel units (dp),
wrap_content, or fill_parent, is a better
approach, because it helps ensure that
your application will display properly
across a variety of device screen sizes.
Demo !!
 XML
 Code
Try !!!
 Create

XML layout that uses a vertical
LinearLayout to hold a TextView and a
Button
 TextView



id = text
Text= “Hello, I am a TextView”

 Button



id=button
text="Hello, I am a Button"
Attributes Examples
 Size,

Padding and Margins

The accepted measurement types:
Px, dp(Density-independent Pixels), sp(Scaleindependent Pixels), pt, in, mm.




We can define it in Dimension Values.
Note
 Although

you can nest one or more
layouts within another layout to achieve
your UI design, you should strive to keep
your layout hierarchy as shallow as
possible.
Your layout draws faster if it has fewer
nested layouts (a wide view hierarchy is
better than a deep view hierarchy).Why?
 As

you can see, the code can rapidly
grow in size as more controls are added
to the screen, making screen contents
more difficult to maintain or reuse.
Exploring Various Layout Types
FrameLayout



designed to display a stack of child View
controls.
This can be used to show multiple controls
within the same screen space
LinearLayout




designed to display child View controls in a
single row or column.(Orientation= vertically
or horizontally.)
This is a very handy layout method for
creating forms.
Note
 To

create a linear layout in which each
child uses the same amount of space on
the screen,
 set the android:layout_height of each
view to "0dp" (for a vertical layout)
 or the android:layout_width of each view
to "0dp" (for a horizontal layout).
 Then set the android:layout_weight of
each view to "1".
Try to make it !!
Hint




if there are three text fields and two of them
declare a weight of 1, while the other is given
no weight, the third text field without weight
will not grow and will only occupy the area
required by its content. The other two will
expand equally to fill the space remaining
after all three fields are measured.
If the third field is then given a weight of 2
(instead of 0), then it is now declared more
important than both the others, so it gets half
the total remaining space, while the first two
share the rest equally.
RelativeLayout




designed to display child View controls in
relation to each other.
You can also align child View controls
relative to the parent edges.
Is a very powerful utility for designing a user
interface because it can eliminate nested
view groups and keep your layout hierarchy
flat, which improves performance.
Positioning Views
android:layout_alignParentTop
If "true", makes the top edge of this view match the
top edge of the parent.
 android:layout_centerVertical
If "true", centers this child vertically within its parent.
 android:layout_below
Positions the top edge of this view below the view
specified with a resource ID.
 android:layout_toRightOf
Positions the left edge of this view to the right of the
view specified with a resource ID.

Try To make it !!
TableLayout



designed to organize child View controls
into rows and columns.
designed to organize child View controls
into rows and columns.
Create From
 First

Name
 Second Name
 Job
 Email
 Submit
 OnClick (Print All of them)
Combining Layouts
 This

means that layout controls can be
nested
Event Listeners
 onClick()
 onLongClick()
 onFocusChange()
 onTouch()
 onKey()
How to Handle Listeners
 Implement

My Listener
 Let Class Implement it

More Related Content

What's hot

01 09 - graphical user interface - basic widgets
01  09 - graphical user interface - basic widgets01  09 - graphical user interface - basic widgets
01 09 - graphical user interface - basic widgetsSiva Kumar reddy Vasipally
 
View groups containers
View groups containersView groups containers
View groups containersMani Selvaraj
 
How to create ui using droid draw
How to create ui using droid drawHow to create ui using droid draw
How to create ui using droid drawinfo_zybotech
 
Best Practices for Android UI by RapidValue Solutions
Best Practices for Android UI by RapidValue SolutionsBest Practices for Android UI by RapidValue Solutions
Best Practices for Android UI by RapidValue SolutionsRapidValue
 
Android training day 3
Android training day 3Android training day 3
Android training day 3Vivek Bhusal
 
Building a simple user interface lesson2
Building a simple user interface lesson2Building a simple user interface lesson2
Building a simple user interface lesson2Kalluri Vinay Reddy
 
Android apps development
Android apps developmentAndroid apps development
Android apps developmentMonir Zzaman
 
Android Tutorial
Android TutorialAndroid Tutorial
Android TutorialFun2Do Labs
 
行動App開發管理實務unit3
行動App開發管理實務unit3行動App開發管理實務unit3
行動App開發管理實務unit3Xavier Yin
 
Android app development lesson 1
Android app development lesson 1Android app development lesson 1
Android app development lesson 1Kalluri Vinay Reddy
 
"Android" mobilių programėlių kūrimo įvadas #2
"Android" mobilių programėlių kūrimo įvadas #2"Android" mobilių programėlių kūrimo įvadas #2
"Android" mobilių programėlių kūrimo įvadas #2Tadas Jurelevičius
 

What's hot (20)

Advance Android Layout Walkthrough
Advance Android Layout WalkthroughAdvance Android Layout Walkthrough
Advance Android Layout Walkthrough
 
Android layouts
Android layoutsAndroid layouts
Android layouts
 
01 09 - graphical user interface - basic widgets
01  09 - graphical user interface - basic widgets01  09 - graphical user interface - basic widgets
01 09 - graphical user interface - basic widgets
 
View groups containers
View groups containersView groups containers
View groups containers
 
01 08 - graphical user interface - layouts
01  08 - graphical user interface - layouts01  08 - graphical user interface - layouts
01 08 - graphical user interface - layouts
 
How to create ui using droid draw
How to create ui using droid drawHow to create ui using droid draw
How to create ui using droid draw
 
Best Practices for Android UI by RapidValue Solutions
Best Practices for Android UI by RapidValue SolutionsBest Practices for Android UI by RapidValue Solutions
Best Practices for Android UI by RapidValue Solutions
 
Ui 5
Ui   5Ui   5
Ui 5
 
Android training day 3
Android training day 3Android training day 3
Android training day 3
 
Unit2
Unit2Unit2
Unit2
 
Day seven
Day sevenDay seven
Day seven
 
Material Design Android
Material Design AndroidMaterial Design Android
Material Design Android
 
Building a simple user interface lesson2
Building a simple user interface lesson2Building a simple user interface lesson2
Building a simple user interface lesson2
 
Android apps development
Android apps developmentAndroid apps development
Android apps development
 
Chapter 5 - Layouts
Chapter 5 - LayoutsChapter 5 - Layouts
Chapter 5 - Layouts
 
Chapter 10 - Views Part 2
Chapter 10 - Views Part 2Chapter 10 - Views Part 2
Chapter 10 - Views Part 2
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
 
行動App開發管理實務unit3
行動App開發管理實務unit3行動App開發管理實務unit3
行動App開發管理實務unit3
 
Android app development lesson 1
Android app development lesson 1Android app development lesson 1
Android app development lesson 1
 
"Android" mobilių programėlių kūrimo įvadas #2
"Android" mobilių programėlių kūrimo įvadas #2"Android" mobilių programėlių kūrimo įvadas #2
"Android" mobilių programėlių kūrimo įvadas #2
 

Viewers also liked

Customizing Theme and Style for Material Design : Droid Kaigi 2016
Customizing Theme and Style for Material Design : Droid Kaigi 2016Customizing Theme and Style for Material Design : Droid Kaigi 2016
Customizing Theme and Style for Material Design : Droid Kaigi 2016Yuki Anzai
 
Head First XML Layout on Android
Head First XML Layout on AndroidHead First XML Layout on Android
Head First XML Layout on AndroidYuki Anzai
 
Android Layout Cookbook Seminor
Android Layout Cookbook SeminorAndroid Layout Cookbook Seminor
Android Layout Cookbook SeminorYuki Anzai
 
Android Basic Tutorial
Android Basic TutorialAndroid Basic Tutorial
Android Basic TutorialSmartmonk
 
Android training day 2
Android training day 2Android training day 2
Android training day 2Vivek Bhusal
 
Android complete basic Guide
Android complete basic GuideAndroid complete basic Guide
Android complete basic GuideAKASH SINGH
 
IT120-3. Thiết kế giao diện trên Android
IT120-3. Thiết kế giao diện trên AndroidIT120-3. Thiết kế giao diện trên Android
IT120-3. Thiết kế giao diện trên AndroidMultiUni
 
Handbook Usability Testing - Capitulo 13
Handbook Usability Testing - Capitulo 13Handbook Usability Testing - Capitulo 13
Handbook Usability Testing - Capitulo 13Luiz Agner
 
WVRHC Desktop Usability Testing
WVRHC Desktop Usability TestingWVRHC Desktop Usability Testing
WVRHC Desktop Usability TestingTim Broadwater
 
Android App Development 02 : Activity & Layout
Android App Development 02 : Activity & LayoutAndroid App Development 02 : Activity & Layout
Android App Development 02 : Activity & LayoutAnuchit Chalothorn
 
DIY mobile usability testing - IA Summit 2011
DIY mobile usability testing - IA Summit 2011DIY mobile usability testing - IA Summit 2011
DIY mobile usability testing - IA Summit 2011Belen Barros Pena
 
Usability & Usability Testing
Usability  & Usability TestingUsability  & Usability Testing
Usability & Usability Testingrebrennan
 
Android2 composant-layout-menu (1)
Android2 composant-layout-menu (1)Android2 composant-layout-menu (1)
Android2 composant-layout-menu (1)Chaikhani Ibtissam
 
Introduction to Web Survey Usability Design and Testing
Introduction to Web Survey Usability Design and TestingIntroduction to Web Survey Usability Design and Testing
Introduction to Web Survey Usability Design and TestingJennifer Romano Bergstrom
 

Viewers also liked (20)

Customizing Theme and Style for Material Design : Droid Kaigi 2016
Customizing Theme and Style for Material Design : Droid Kaigi 2016Customizing Theme and Style for Material Design : Droid Kaigi 2016
Customizing Theme and Style for Material Design : Droid Kaigi 2016
 
Head First XML Layout on Android
Head First XML Layout on AndroidHead First XML Layout on Android
Head First XML Layout on Android
 
Android Layout Cookbook Seminor
Android Layout Cookbook SeminorAndroid Layout Cookbook Seminor
Android Layout Cookbook Seminor
 
Android Basic Tutorial
Android Basic TutorialAndroid Basic Tutorial
Android Basic Tutorial
 
Cisco CCNA module 3
Cisco CCNA module 3Cisco CCNA module 3
Cisco CCNA module 3
 
Cisco CCNA module 2
Cisco CCNA module 2Cisco CCNA module 2
Cisco CCNA module 2
 
Cisco CCNA module 4
Cisco CCNA module 4Cisco CCNA module 4
Cisco CCNA module 4
 
Android training day 2
Android training day 2Android training day 2
Android training day 2
 
Android complete basic Guide
Android complete basic GuideAndroid complete basic Guide
Android complete basic Guide
 
IT120-3. Thiết kế giao diện trên Android
IT120-3. Thiết kế giao diện trên AndroidIT120-3. Thiết kế giao diện trên Android
IT120-3. Thiết kế giao diện trên Android
 
Handbook Usability Testing - Capitulo 13
Handbook Usability Testing - Capitulo 13Handbook Usability Testing - Capitulo 13
Handbook Usability Testing - Capitulo 13
 
WVRHC Desktop Usability Testing
WVRHC Desktop Usability TestingWVRHC Desktop Usability Testing
WVRHC Desktop Usability Testing
 
Android App Development 02 : Activity & Layout
Android App Development 02 : Activity & LayoutAndroid App Development 02 : Activity & Layout
Android App Development 02 : Activity & Layout
 
Usability Tests
Usability TestsUsability Tests
Usability Tests
 
DIY mobile usability testing - IA Summit 2011
DIY mobile usability testing - IA Summit 2011DIY mobile usability testing - IA Summit 2011
DIY mobile usability testing - IA Summit 2011
 
Usability & Usability Testing
Usability  & Usability TestingUsability  & Usability Testing
Usability & Usability Testing
 
Android2 composant-layout-menu (1)
Android2 composant-layout-menu (1)Android2 composant-layout-menu (1)
Android2 composant-layout-menu (1)
 
Intranet Usability Testing
Intranet Usability TestingIntranet Usability Testing
Intranet Usability Testing
 
Introduction to Web Survey Usability Design and Testing
Introduction to Web Survey Usability Design and TestingIntroduction to Web Survey Usability Design and Testing
Introduction to Web Survey Usability Design and Testing
 
Cisco CCNA module 1
Cisco CCNA module 1Cisco CCNA module 1
Cisco CCNA module 1
 

Similar to Android Training (Android UI)

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
 
04 user interfaces
04 user interfaces04 user interfaces
04 user interfacesC.o. Nieto
 
mobile application development -unit-3-
mobile application development  -unit-3-mobile application development  -unit-3-
mobile application development -unit-3-TejamFandat
 
Tk2323 lecture 2 ui
Tk2323 lecture 2   uiTk2323 lecture 2   ui
Tk2323 lecture 2 uiMengChun Lam
 
Android Study Jam 2
Android Study Jam 2Android Study Jam 2
Android Study Jam 2DSC GVP
 
03 layouts & ui design - Android
03   layouts & ui design - Android03   layouts & ui design - Android
03 layouts & ui design - AndroidWingston
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1Isham Rashik
 
W1_Lec01_Lec02_Layouts.pptx
W1_Lec01_Lec02_Layouts.pptxW1_Lec01_Lec02_Layouts.pptx
W1_Lec01_Lec02_Layouts.pptxssuserc1e786
 
DevFest Sul 2014 - Android 4 lazy iOS Devs
DevFest Sul 2014 - Android 4 lazy iOS DevsDevFest Sul 2014 - Android 4 lazy iOS Devs
DevFest Sul 2014 - Android 4 lazy iOS DevsJackson F. de A. Mafra
 
Lecture 02: Android Layouts.pptx
Lecture 02: Android Layouts.pptxLecture 02: Android Layouts.pptx
Lecture 02: Android Layouts.pptxYousef Alamir
 

Similar to Android Training (Android UI) (20)

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
 
04 user interfaces
04 user interfaces04 user interfaces
04 user interfaces
 
Android UI Fundamentals part 1
Android UI Fundamentals part 1Android UI Fundamentals part 1
Android UI Fundamentals part 1
 
Android xml-based layouts-chapter5
Android xml-based layouts-chapter5Android xml-based layouts-chapter5
Android xml-based layouts-chapter5
 
Android views and layouts-chapter4
Android views and layouts-chapter4Android views and layouts-chapter4
Android views and layouts-chapter4
 
Hello Android
Hello AndroidHello Android
Hello Android
 
Android ui with xml
Android ui with xmlAndroid ui with xml
Android ui with xml
 
Android Ui
Android UiAndroid Ui
Android Ui
 
Android UI
Android UI Android UI
Android UI
 
mobile application development -unit-3-
mobile application development  -unit-3-mobile application development  -unit-3-
mobile application development -unit-3-
 
Tk2323 lecture 2 ui
Tk2323 lecture 2   uiTk2323 lecture 2   ui
Tk2323 lecture 2 ui
 
Android Study Jam 2
Android Study Jam 2Android Study Jam 2
Android Study Jam 2
 
03 layouts & ui design - Android
03   layouts & ui design - Android03   layouts & ui design - Android
03 layouts & ui design - Android
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1
 
W1_Lec01_Lec02_Layouts.pptx
W1_Lec01_Lec02_Layouts.pptxW1_Lec01_Lec02_Layouts.pptx
W1_Lec01_Lec02_Layouts.pptx
 
DevFest Sul 2014 - Android 4 lazy iOS Devs
DevFest Sul 2014 - Android 4 lazy iOS DevsDevFest Sul 2014 - Android 4 lazy iOS Devs
DevFest Sul 2014 - Android 4 lazy iOS Devs
 
Lecture 02: Android Layouts.pptx
Lecture 02: Android Layouts.pptxLecture 02: Android Layouts.pptx
Lecture 02: Android Layouts.pptx
 
Ap quiz app
Ap quiz appAp quiz app
Ap quiz app
 
Chapter1 introduction
Chapter1 introductionChapter1 introduction
Chapter1 introduction
 
List Views
List ViewsList Views
List Views
 

More from Khaled Anaqwa

Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)Khaled Anaqwa
 
Android Training (Content Provider)
Android Training (Content Provider)Android Training (Content Provider)
Android Training (Content Provider)Khaled Anaqwa
 
Android Training (Services)
Android Training (Services)Android Training (Services)
Android Training (Services)Khaled Anaqwa
 
Android Training (Notifications)
Android Training (Notifications)Android Training (Notifications)
Android Training (Notifications)Khaled Anaqwa
 
Android Training (Broadcast Receiver)
Android Training (Broadcast Receiver)Android Training (Broadcast Receiver)
Android Training (Broadcast Receiver)Khaled Anaqwa
 
Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)Khaled Anaqwa
 
Android Training (Animation)
Android Training (Animation)Android Training (Animation)
Android Training (Animation)Khaled Anaqwa
 
Android Training (Touch)
Android Training (Touch)Android Training (Touch)
Android Training (Touch)Khaled Anaqwa
 
Android Training (Sensors)
Android Training (Sensors)Android Training (Sensors)
Android Training (Sensors)Khaled Anaqwa
 
Android Training (Media)
Android Training (Media)Android Training (Media)
Android Training (Media)Khaled Anaqwa
 
Android Training (AdapterView & Adapter)
Android Training (AdapterView & Adapter)Android Training (AdapterView & Adapter)
Android Training (AdapterView & Adapter)Khaled Anaqwa
 
Android Training (ScrollView , Horizontal ScrollView WebView)
Android Training (ScrollView , Horizontal ScrollView  WebView)Android Training (ScrollView , Horizontal ScrollView  WebView)
Android Training (ScrollView , Horizontal ScrollView WebView)Khaled Anaqwa
 
Android training (android style)
Android training (android style)Android training (android style)
Android training (android style)Khaled Anaqwa
 
Android Training (Intro)
Android Training (Intro)Android Training (Intro)
Android Training (Intro)Khaled Anaqwa
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)Khaled Anaqwa
 
Android Training (android fundamental)
Android Training (android fundamental)Android Training (android fundamental)
Android Training (android fundamental)Khaled Anaqwa
 

More from Khaled Anaqwa (16)

Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)
 
Android Training (Content Provider)
Android Training (Content Provider)Android Training (Content Provider)
Android Training (Content Provider)
 
Android Training (Services)
Android Training (Services)Android Training (Services)
Android Training (Services)
 
Android Training (Notifications)
Android Training (Notifications)Android Training (Notifications)
Android Training (Notifications)
 
Android Training (Broadcast Receiver)
Android Training (Broadcast Receiver)Android Training (Broadcast Receiver)
Android Training (Broadcast Receiver)
 
Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)Android Training (Storing data using SQLite)
Android Training (Storing data using SQLite)
 
Android Training (Animation)
Android Training (Animation)Android Training (Animation)
Android Training (Animation)
 
Android Training (Touch)
Android Training (Touch)Android Training (Touch)
Android Training (Touch)
 
Android Training (Sensors)
Android Training (Sensors)Android Training (Sensors)
Android Training (Sensors)
 
Android Training (Media)
Android Training (Media)Android Training (Media)
Android Training (Media)
 
Android Training (AdapterView & Adapter)
Android Training (AdapterView & Adapter)Android Training (AdapterView & Adapter)
Android Training (AdapterView & Adapter)
 
Android Training (ScrollView , Horizontal ScrollView WebView)
Android Training (ScrollView , Horizontal ScrollView  WebView)Android Training (ScrollView , Horizontal ScrollView  WebView)
Android Training (ScrollView , Horizontal ScrollView WebView)
 
Android training (android style)
Android training (android style)Android training (android style)
Android training (android style)
 
Android Training (Intro)
Android Training (Intro)Android Training (Intro)
Android Training (Intro)
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)
 
Android Training (android fundamental)
Android Training (android fundamental)Android Training (android fundamental)
Android Training (android fundamental)
 

Recently uploaded

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
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
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 

Recently uploaded (20)

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
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
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 

Android Training (Android UI)

  • 2. As if a device can function if it has no style. As if a device can be called stylish that does not function superbly.... Yes, beauty matters. Boy, does it matter. It is not surface, it is not an extra, it is the thing itself. —STEPHEN FRY, THE GUARDIAN (OCTOBER 27, 2007)
  • 3. User Interface     All user interface elements in an Android app are built using View and ViewGroup objects. A View is an object that draws something on the screen that the user can interact with. A ViewGroup is an object that holds other View (and ViewGroup) objects in order to define the layout of the interface. The user interface for each component of your app is defined using a hierarchy of View and ViewGroup objects.
  • 4.  This hierarchy tree can be as simple or complex as you need it to be.
  • 5. Layouts  A layout defines the visual structure for a user interface, such as the UI for an activity or app widget.  You can declare a layout in two ways: Declare UI elements in XML.  Instantiate layout elements at runtime    The Android framework gives you the flexibility to use either or both . The advantage to declaring your UI in XML is that it enables you to better separate the presentation from the code that controls its behavior.
  • 6. Using Eclipse to Design Layout Resources  Use the Outline pane to Add and Remove controls to your layout resource.  Select a specific control (either in the Preview or the Outline) and use the Property pane to adjust a specific control’s attributes.  Use the XML tab to edit the XML definition directly.
  • 7. Write the XML  Each layout file must contain exactly one root element.  XML vocabulary for declaring UI elements closely follows the structure and naming of the classes and methods.  For example, the EditText element has a text attribute that corresponds to EditText.setText().
  • 8. Attributes Overview     Every View and ViewGroup object supports their own variety of XML attributes. Some attributes are specific (e.g. TextView supports the textSize attribute) These attributes are also inherited by any View objects that may extend this class. Some are common to all View objects, because they are inherited from the root View class (like the id attribute).
  • 9. Attributes Examples  ID (Any View object may have an integer ID associated with it, to uniquely identify the View within the tree.)     android:id="@+id/my_button” The at-symbol (@) at the beginning of the string indicates that the XML parser should parse and expand the rest of the ID string and identify it as an ID resource. The plus-symbol (+) means that this is a new resource name that must be created and added to our resources (in the R.java file) android:id="@android:id/empty” (from android.R)
  • 10. Demo  Create View in xml  Create the same view in code
  • 11. Question? If I Instantiate view at runtime how I can assign ID to it ?
  • 12. Attributes Examples  Layout Parameters (XML layout attributes named layout_something )   for the View that are appropriate for the ViewGroup in which it resides. All view groups include a width and height (layout_width and layout_height), and each view is required to define them. wrap_content tells your view to size itself to the dimensions required by its content  fill_parent (renamed match_parent in API Level 8) tells your view to become as big as its parent view group will allow. 
  • 13.
  • 14.  Every LayoutParams subclass has its own syntax for setting values. Each child element must define LayoutParams that are appropriate for its parent, though it may also define different LayoutParams for its own children.
  • 15. Note (not Galaxy Note)  specifying a layout width and height using absolute units such as pixels is not recommended. Instead, using relative measurements such as densityindependent pixel units (dp), wrap_content, or fill_parent, is a better approach, because it helps ensure that your application will display properly across a variety of device screen sizes.
  • 17. Try !!!  Create XML layout that uses a vertical LinearLayout to hold a TextView and a Button  TextView   id = text Text= “Hello, I am a TextView”  Button   id=button text="Hello, I am a Button"
  • 18. Attributes Examples  Size, Padding and Margins The accepted measurement types: Px, dp(Density-independent Pixels), sp(Scaleindependent Pixels), pt, in, mm.   We can define it in Dimension Values.
  • 19. Note  Although you can nest one or more layouts within another layout to achieve your UI design, you should strive to keep your layout hierarchy as shallow as possible. Your layout draws faster if it has fewer nested layouts (a wide view hierarchy is better than a deep view hierarchy).Why?
  • 20.
  • 21.  As you can see, the code can rapidly grow in size as more controls are added to the screen, making screen contents more difficult to maintain or reuse.
  • 23. FrameLayout   designed to display a stack of child View controls. This can be used to show multiple controls within the same screen space
  • 24. LinearLayout   designed to display child View controls in a single row or column.(Orientation= vertically or horizontally.) This is a very handy layout method for creating forms.
  • 25. Note  To create a linear layout in which each child uses the same amount of space on the screen,  set the android:layout_height of each view to "0dp" (for a vertical layout)  or the android:layout_width of each view to "0dp" (for a horizontal layout).  Then set the android:layout_weight of each view to "1".
  • 26. Try to make it !!
  • 27. Hint   if there are three text fields and two of them declare a weight of 1, while the other is given no weight, the third text field without weight will not grow and will only occupy the area required by its content. The other two will expand equally to fill the space remaining after all three fields are measured. If the third field is then given a weight of 2 (instead of 0), then it is now declared more important than both the others, so it gets half the total remaining space, while the first two share the rest equally.
  • 28. RelativeLayout    designed to display child View controls in relation to each other. You can also align child View controls relative to the parent edges. Is a very powerful utility for designing a user interface because it can eliminate nested view groups and keep your layout hierarchy flat, which improves performance.
  • 29. Positioning Views android:layout_alignParentTop If "true", makes the top edge of this view match the top edge of the parent.  android:layout_centerVertical If "true", centers this child vertically within its parent.  android:layout_below Positions the top edge of this view below the view specified with a resource ID.  android:layout_toRightOf Positions the left edge of this view to the right of the view specified with a resource ID. 
  • 30. Try To make it !!
  • 31. TableLayout   designed to organize child View controls into rows and columns. designed to organize child View controls into rows and columns.
  • 32. Create From  First Name  Second Name  Job  Email  Submit  OnClick (Print All of them)
  • 33. Combining Layouts  This means that layout controls can be nested
  • 34. Event Listeners  onClick()  onLongClick()  onFocusChange()  onTouch()  onKey()
  • 35. How to Handle Listeners  Implement My Listener  Let Class Implement it

Editor's Notes

  1. Create an ids.xml file and place all your required ids in it as below<?xml version="1.0" encoding="utf-8"?><resources> <item type="id" name="layout1" /> <item type="id" name="layout2" /> <item type="id" name="layout3" /></resources>Now for your dynamically created layouts or views you can use these ids as belownew_layout1.setId(R.id.layout1);new_view2.setId(R.id.layout2);new_layout3.setId(R.id.layout3);
  2. <?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextViewandroid:id="@+id/text"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Hello, I am a TextView" /> <Button android:id="@+id/button"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Hello, I am a Button" /></LinearLayout>
  3. One View May Cause Bottle Neck …
  4. <?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><EditTextandroid:id="@+id/editText1"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_weight="1"android:gravity="center"android:text="editText1" /><EditTextandroid:id="@+id/editText2"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_weight="2"android:gravity="center" android:text="editText2" /><EditTextandroid:id="@+id/editText3"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_weight="1"android:gravity="center"android:text="editText3" /><EditTextandroid:id="@+id/editText4"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_weight="3"android:gravity="center"android:text="editText4" /></LinearLayout>
  5. <?xml version="1.0" encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:paddingLeft="16dp"android:paddingRight="16dp" > <EditTextandroid:id="@+id/name"android:layout_width="fill_parent"android:layout_height="wrap_content"android:hint="@string/reminder" /> <Spinnerandroid:id="@+id/dates"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_below="@id/name"android:layout_alignParentLeft="true"android:layout_toLeftOf="@+id/times" /> <Spinnerandroid:id="@id/times"android:layout_width="96dp"android:layout_height="wrap_content"android:layout_below="@id/name"android:layout_alignParentRight="true" /> <Buttonandroid:layout_width="96dp"android:layout_height="wrap_content"android:layout_below="@id/times"android:layout_alignParentRight="true"android:text="@string/done" /></RelativeLayout>