SlideShare ist ein Scribd-Unternehmen logo
1 von 21
Android	
  User	
  
  Interface	
  


 Marko	
  Gargenta	
  
   Marakana	
  
HELLO	
  WORLD!	
  
Create	
  New	
  Project
                                         	
  
Use the Eclipse tool to create a new
Android project.

Here are some key constructs:


Project	
          Eclipse	
  construct	
  
Target	
           minimum	
  to	
  run	
  
App	
  name	
      whatever	
  
Package	
          Java	
  package	
  
AcBvity	
          Java	
  class	
  
The	
  Manifest	
  File	
  
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.marakana"
   android:versionCode="1"
   android:versionName="1.0">
  <application android:icon="@drawable/icon"
        android:label="@string/app_name">
    <activity android:name=".HelloAndroid"
           android:label="@string/app_name">
       <intent-filter>
          <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />
       </intent-filter>
    </activity>
  </application>
  <uses-sdk android:minSdkVersion="5" />
</manifest>
The	
  Layout	
  Resource	
  

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  >
<TextView
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:text="@string/hello"
  />
</LinearLayout>
The	
  Java	
  File	
  
package com.marakana;

import android.app.Activity;
import android.os.Bundle;

public class HelloAndroid extends Activity {
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.main);
  }
}
ANDROID	
  USER	
  INTERFACE	
  
Two	
  UI	
  Approaches	
  
Procedural	
                              Declara;ve	
  
You	
  write	
  Java	
  code	
            You	
  write	
  XML	
  code	
  
Similar	
  to	
  Swing	
  or	
  AWT	
     Similar	
  to	
  HTML	
  of	
  a	
  web	
  page	
  




You can mix and match both styles.
Declarative is preferred: easier and
more tools
XML-­‐Based	
  User	
  Interface	
  




Use WYSIWYG tools to build powerful XML-based UI.
Easily customize it from Java. Separate concerns.
Dips	
  and	
  Sps	
  

px	
  (pixel)	
                                 Dots	
  on	
  the	
  screen	
  
in	
  (inches)	
                                Size	
  as	
  measured	
  by	
  a	
  ruler	
  
mm	
  (millimeters)	
                           Size	
  as	
  measured	
  by	
  a	
  ruler	
  
pt	
  (points)	
                                1/72	
  of	
  an	
  inch	
  
dp	
  (density-­‐independent	
  pixel)	
        Abstract	
  unit.	
  On	
  screen	
  with	
  160dpi,	
  
                                                1dp=1px	
  
dip	
                                           synonym	
  for	
  dp	
  and	
  o^en	
  used	
  by	
  Google	
  
sp	
                                            Similar	
  to	
  dp	
  but	
  also	
  scaled	
  by	
  users	
  font	
  
                                                size	
  preference	
  
Views	
  and	
  Layouts
                          	
  

                    ViewGroup




        ViewGroup               View




 View     View      View




ViewGroups contain other Views but
are also Views themselves.
Common	
  UI	
  Components
                                	
  
Android UI includes many
common modern UI
widgets, such as Buttons,
Tabs, Progress Bars, Date
and Time Pickers, etc.
SelecBon	
  Components
                              	
  

Some UI widgets may
be linked to zillions of
pieces of data.
Examples are ListView
and Spinners
(pull-downs).
Adapters
                         	
  


                      Adapter       Data
                                   Source




To make sure they run smoothly, Android uses
Adapters to connect them to their data sources. A
typical data source is an Array or a Database.
Complex	
  Components
                            	
  
Certain high-level components are simply
available just like Views. Adding a Map or a
Video to your application is almost like adding a
Button or a piece of text.
Menus	
  and	
  Dialogs
                      	
  
Graphics	
  &	
  AnimaBon	
  
Android has rich support for 2D graphics.
You can draw & animate from XML.
You can use OpenGL for 3D graphics.
MulBmedia	
  
AudioPlayer lets you simply specify
the audio resource and play it.

VideoView is a View that you can
drop anywhere in your activity, point
to a video file and play it.

XML:
<VideoView
  android:id="@+id/video"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:layout_gravity="center” />

Java:
player = (VideoView) findViewById(R.id.video);
player.setVideoPath("/sdcard/samplevideo.3gp");
player.start();
Google	
  Maps
                                      	
  
Google Maps is an add-on in Android.
It is not part of open-source project.

However, adding Maps is relatively
easy using MapView.


XML:
<com.google.android.maps.MapView
android:id="@+id/map"
android:clickable="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0EfLSgdSCWIN…A"
/>
Building	
  UI	
  for	
  Performance	
  




A handy Hierarchy Viewer tool helps with optimizing the UI for performance
Summary	
  
     Main difference between Java and
     Android is User Interface.

     Android has two approaches to UI:
     programmatic and declarative. Best
     practice is to use both.

     Lifecycle of an activity is very
     important for overall performance of
     your app. So, optimize your UI.



     Marko Gargenta, Marakana.com
     marko@marakana.com
     +1-415-647-7000

     Licensed under Creative Commons
     License (cc-by-nc-nd). Please Share!

Weitere ähnliche Inhalte

Was ist angesagt?

Londroid Android Home Screen Widgets
Londroid Android Home Screen WidgetsLondroid Android Home Screen Widgets
Londroid Android Home Screen Widgets
Richard Hyndman
 
Android Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAndroid Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver Tutorial
Ahsanul Karim
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI Widgets
Ahsanul Karim
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
Ahsanul Karim
 
Day 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through ActivitiesDay 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through Activities
Ahsanul Karim
 
android layouts
android layoutsandroid layouts
android layouts
Deepa Rani
 
View groups containers
View groups containersView groups containers
View groups containers
Mani Selvaraj
 
Lecture 3 getting active through activities
Lecture 3 getting active through activities Lecture 3 getting active through activities
Lecture 3 getting active through activities
Ahsanul Karim
 
Android ui layout
Android ui layoutAndroid ui layout
Android ui layout
Krazy Koder
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 

Was ist angesagt? (20)

Android session 2
Android session 2Android session 2
Android session 2
 
Android Widget
Android WidgetAndroid Widget
Android Widget
 
Android session 3
Android session 3Android session 3
Android session 3
 
Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1Android Tutorial For Beginners Part-1
Android Tutorial For Beginners Part-1
 
Londroid Android Home Screen Widgets
Londroid Android Home Screen WidgetsLondroid Android Home Screen Widgets
Londroid Android Home Screen Widgets
 
Android UI
Android UIAndroid UI
Android UI
 
Android session 1
Android session 1Android session 1
Android session 1
 
Android Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAndroid Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver Tutorial
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI Widgets
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
 
Day 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through ActivitiesDay 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through Activities
 
android layouts
android layoutsandroid layouts
android layouts
 
Unit2
Unit2Unit2
Unit2
 
View groups containers
View groups containersView groups containers
View groups containers
 
Android Services
Android ServicesAndroid Services
Android Services
 
Lecture 3 getting active through activities
Lecture 3 getting active through activities Lecture 3 getting active through activities
Lecture 3 getting active through activities
 
04 user interfaces
04 user interfaces04 user interfaces
04 user interfaces
 
Android xml-based layouts-chapter5
Android xml-based layouts-chapter5Android xml-based layouts-chapter5
Android xml-based layouts-chapter5
 
Android ui layout
Android ui layoutAndroid ui layout
Android ui layout
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
 

Andere mochten auch

Corporate Wellness - Presented by Beneplan & the House of Verona
Corporate Wellness - Presented by Beneplan & the House of VeronaCorporate Wellness - Presented by Beneplan & the House of Verona
Corporate Wellness - Presented by Beneplan & the House of Verona
Yafa Sakkejha
 
Rusu 2012 clubs affil pack
Rusu 2012 clubs affil packRusu 2012 clubs affil pack
Rusu 2012 clubs affil pack
Mohammad Hassan
 
24015127 Consell Social De La Llengua Catalana Llengua I Joves
24015127 Consell Social De La Llengua Catalana Llengua I Joves24015127 Consell Social De La Llengua Catalana Llengua I Joves
24015127 Consell Social De La Llengua Catalana Llengua I Joves
Arnau Cerdà
 
Reinforcement 4
Reinforcement 4Reinforcement 4
Reinforcement 4
Sonia
 
Copia De Loba
Copia De LobaCopia De Loba
Copia De Loba
amezola
 

Andere mochten auch (20)

Corporate Wellness - Presented by Beneplan & the House of Verona
Corporate Wellness - Presented by Beneplan & the House of VeronaCorporate Wellness - Presented by Beneplan & the House of Verona
Corporate Wellness - Presented by Beneplan & the House of Verona
 
Smoking Hypnosis - Say No To The Cancer Sticks
Smoking Hypnosis - Say No To The Cancer SticksSmoking Hypnosis - Say No To The Cancer Sticks
Smoking Hypnosis - Say No To The Cancer Sticks
 
Presentación earth, air, weather, pollution
Presentación earth, air, weather, pollutionPresentación earth, air, weather, pollution
Presentación earth, air, weather, pollution
 
Your Data, Your Interface
Your Data, Your InterfaceYour Data, Your Interface
Your Data, Your Interface
 
Resursele Regenerabile (2)
Resursele Regenerabile  (2)Resursele Regenerabile  (2)
Resursele Regenerabile (2)
 
Rusu 2012 clubs affil pack
Rusu 2012 clubs affil packRusu 2012 clubs affil pack
Rusu 2012 clubs affil pack
 
Llengües d'origen 30 setembre 2011
Llengües d'origen 30 setembre 2011Llengües d'origen 30 setembre 2011
Llengües d'origen 30 setembre 2011
 
Mitä mun puhelin2909
Mitä mun puhelin2909Mitä mun puhelin2909
Mitä mun puhelin2909
 
Quick prototyping apps using JS - Ciklum, Vinnitsa
Quick prototyping apps using JS - Ciklum, VinnitsaQuick prototyping apps using JS - Ciklum, Vinnitsa
Quick prototyping apps using JS - Ciklum, Vinnitsa
 
Alan Stevens - #smib10 Presentation
Alan Stevens - #smib10 Presentation Alan Stevens - #smib10 Presentation
Alan Stevens - #smib10 Presentation
 
Marketing Innovation In India
Marketing Innovation In IndiaMarketing Innovation In India
Marketing Innovation In India
 
Creative loverz (workshop)
Creative loverz (workshop)Creative loverz (workshop)
Creative loverz (workshop)
 
David Parfect - #smib10 Presentation
David Parfect - #smib10 Presentation David Parfect - #smib10 Presentation
David Parfect - #smib10 Presentation
 
Android for Java Developers at OSCON 2010
Android for Java Developers at OSCON 2010Android for Java Developers at OSCON 2010
Android for Java Developers at OSCON 2010
 
24015127 Consell Social De La Llengua Catalana Llengua I Joves
24015127 Consell Social De La Llengua Catalana Llengua I Joves24015127 Consell Social De La Llengua Catalana Llengua I Joves
24015127 Consell Social De La Llengua Catalana Llengua I Joves
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Effective Benefit Plan Administration
Effective Benefit Plan AdministrationEffective Benefit Plan Administration
Effective Benefit Plan Administration
 
Reinforcement 4
Reinforcement 4Reinforcement 4
Reinforcement 4
 
Copia De Loba
Copia De LobaCopia De Loba
Copia De Loba
 
New Orleans Tag11 09 Linked In
New Orleans Tag11 09 Linked InNew Orleans Tag11 09 Linked In
New Orleans Tag11 09 Linked In
 

Ähnlich wie Marakana Android User Interface

Basic android development
Basic android developmentBasic android development
Basic android development
Upanya Singh
 
Basic android development
Basic android developmentBasic android development
Basic android development
Upanya Singh
 
Build Mobile Application In Android
Build Mobile Application In AndroidBuild Mobile Application In Android
Build Mobile Application In Android
dnnddane
 
Synapseindia android apps intro to android development
Synapseindia android apps  intro to android developmentSynapseindia android apps  intro to android development
Synapseindia android apps intro to android development
Synapseindiappsdevelopment
 

Ähnlich wie Marakana Android User Interface (20)

PPT Companion to Android
PPT Companion to AndroidPPT Companion to Android
PPT Companion to Android
 
Android Deep Dive
Android Deep DiveAndroid Deep Dive
Android Deep Dive
 
Basic android development
Basic android developmentBasic android development
Basic android development
 
Basic android development
Basic android developmentBasic android development
Basic android development
 
Java talks. Android intoduction for develompment
Java talks. Android intoduction for develompmentJava talks. Android intoduction for develompment
Java talks. Android intoduction for develompment
 
Build Mobile Application In Android
Build Mobile Application In AndroidBuild Mobile Application In Android
Build Mobile Application In Android
 
Technology and Android.pptx
Technology and Android.pptxTechnology and Android.pptx
Technology and Android.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
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Android
AndroidAndroid
Android
 
Industrial Training in Android Application
Industrial Training in Android ApplicationIndustrial Training in Android Application
Industrial Training in Android Application
 
Synapseindia android apps intro to android development
Synapseindia android apps  intro to android developmentSynapseindia android apps  intro to android development
Synapseindia android apps intro to android development
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...
Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...
Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2
 
Android app development ppt
Android app development pptAndroid app development ppt
Android app development ppt
 
Nativa Android Applications development
Nativa Android Applications developmentNativa Android Applications development
Nativa Android Applications development
 
Mobile application development
Mobile application developmentMobile application development
Mobile application development
 
Intro to android (gdays)
Intro to android (gdays)Intro to android (gdays)
Intro to android (gdays)
 

Mehr von Marko Gargenta

Mehr von Marko Gargenta (13)

Open Android
Open AndroidOpen Android
Open Android
 
LTE: Building New Killer Apps
LTE: Building New Killer AppsLTE: Building New Killer Apps
LTE: Building New Killer Apps
 
Java Champion Wanted
Java Champion WantedJava Champion Wanted
Java Champion Wanted
 
Android Beyond The Phone
Android Beyond The PhoneAndroid Beyond The Phone
Android Beyond The Phone
 
Android for Java Developers
Android for Java DevelopersAndroid for Java Developers
Android for Java Developers
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Android: A 9,000-foot Overview
Android: A 9,000-foot OverviewAndroid: A 9,000-foot Overview
Android: A 9,000-foot Overview
 
Marakana Android Internals
Marakana Android InternalsMarakana Android Internals
Marakana Android Internals
 
Scrum Overview
Scrum OverviewScrum Overview
Scrum Overview
 
Android For Managers Slides
Android For Managers SlidesAndroid For Managers Slides
Android For Managers Slides
 
Why Python by Marilyn Davis, Marakana
Why Python by Marilyn Davis, MarakanaWhy Python by Marilyn Davis, Marakana
Why Python by Marilyn Davis, Marakana
 
Jens Østergaard on Why Scrum Is So Hard
Jens Østergaard on Why Scrum Is So HardJens Østergaard on Why Scrum Is So Hard
Jens Østergaard on Why Scrum Is So Hard
 
Jens Østergaard on Why Scrum Is So Hard
Jens Østergaard on Why Scrum Is So HardJens Østergaard on Why Scrum Is So Hard
Jens Østergaard on Why Scrum Is So Hard
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Marakana Android User Interface

  • 1. Android  User   Interface   Marko  Gargenta   Marakana  
  • 3. Create  New  Project   Use the Eclipse tool to create a new Android project. Here are some key constructs: Project   Eclipse  construct   Target   minimum  to  run   App  name   whatever   Package   Java  package   AcBvity   Java  class  
  • 4. The  Manifest  File   <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.marakana" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".HelloAndroid" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="5" /> </manifest>
  • 5. The  Layout  Resource   <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> </LinearLayout>
  • 6. The  Java  File   package com.marakana; import android.app.Activity; import android.os.Bundle; public class HelloAndroid extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } }
  • 8. Two  UI  Approaches   Procedural   Declara;ve   You  write  Java  code   You  write  XML  code   Similar  to  Swing  or  AWT   Similar  to  HTML  of  a  web  page   You can mix and match both styles. Declarative is preferred: easier and more tools
  • 9. XML-­‐Based  User  Interface   Use WYSIWYG tools to build powerful XML-based UI. Easily customize it from Java. Separate concerns.
  • 10. Dips  and  Sps   px  (pixel)   Dots  on  the  screen   in  (inches)   Size  as  measured  by  a  ruler   mm  (millimeters)   Size  as  measured  by  a  ruler   pt  (points)   1/72  of  an  inch   dp  (density-­‐independent  pixel)   Abstract  unit.  On  screen  with  160dpi,   1dp=1px   dip   synonym  for  dp  and  o^en  used  by  Google   sp   Similar  to  dp  but  also  scaled  by  users  font   size  preference  
  • 11. Views  and  Layouts   ViewGroup ViewGroup View View View View ViewGroups contain other Views but are also Views themselves.
  • 12. Common  UI  Components   Android UI includes many common modern UI widgets, such as Buttons, Tabs, Progress Bars, Date and Time Pickers, etc.
  • 13. SelecBon  Components   Some UI widgets may be linked to zillions of pieces of data. Examples are ListView and Spinners (pull-downs).
  • 14. Adapters   Adapter Data Source To make sure they run smoothly, Android uses Adapters to connect them to their data sources. A typical data source is an Array or a Database.
  • 15. Complex  Components   Certain high-level components are simply available just like Views. Adding a Map or a Video to your application is almost like adding a Button or a piece of text.
  • 17. Graphics  &  AnimaBon   Android has rich support for 2D graphics. You can draw & animate from XML. You can use OpenGL for 3D graphics.
  • 18. MulBmedia   AudioPlayer lets you simply specify the audio resource and play it. VideoView is a View that you can drop anywhere in your activity, point to a video file and play it. XML: <VideoView android:id="@+id/video" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center” /> Java: player = (VideoView) findViewById(R.id.video); player.setVideoPath("/sdcard/samplevideo.3gp"); player.start();
  • 19. Google  Maps   Google Maps is an add-on in Android. It is not part of open-source project. However, adding Maps is relatively easy using MapView. XML: <com.google.android.maps.MapView android:id="@+id/map" android:clickable="true" android:layout_width="fill_parent" android:layout_height="fill_parent" android:apiKey="0EfLSgdSCWIN…A" />
  • 20. Building  UI  for  Performance   A handy Hierarchy Viewer tool helps with optimizing the UI for performance
  • 21. Summary   Main difference between Java and Android is User Interface. Android has two approaches to UI: programmatic and declarative. Best practice is to use both. Lifecycle of an activity is very important for overall performance of your app. So, optimize your UI. Marko Gargenta, Marakana.com marko@marakana.com +1-415-647-7000 Licensed under Creative Commons License (cc-by-nc-nd). Please Share!