15
Android GUI By: Jeremy Smith

Android GUI

  • Upload
    chaka

  • View
    47

  • Download
    0

Embed Size (px)

DESCRIPTION

By: Jeremy Smith. Android GUI. Table of Contents. Introduction Droid Draw Add XML file Layouts LinearLayout RelativeLayout Objects Notifications Toast Status Bar Dialog Menus Events Listeners Handlers Focus Source. Introduction. - PowerPoint PPT Presentation

Citation preview

Page 1: Android GUI

Android GUIBy: Jeremy Smith

Page 2: Android GUI

Table of Contents Introduction Droid Draw Add XML file Layouts

LinearLayout RelativeLayout

Objects Notifications

Toast Status Bar Dialog

Menus Events

Listeners Handlers Focus

Source

Page 3: Android GUI

Introduction In Android, the UI is built using View and

ViewGroup objects. Views are a base for subclasses called

“Widgets,” which offer fully implemented UI objects. (Ex. Text fields and buttons)

ViewGroups are a base for “layouts,” which offer different kinds of layout architectures.

Android GUI’s are coded in a version of XML and are based on the Views and ViewGroups.

Page 4: Android GUI

Droid Draw (www.droiddraw.org)

Page 5: Android GUI

Adding XML Files

Add an Android specific XML file to a project.

1. In your android project open up the res folder.

2. Then open the layout folder and you will see a generic file called main.xml

3. To add a XML file simply right click and add a new file. Under Android select the Android XML file and you have a brand new XML file open to edit in your project.

Page 6: Android GUI

Layouts Writing XML ( Android has its own XML vocabulary )

Used for designing UI layouts and screen elements Each layout must have only one root element. (parent)

After you create an initial layout you can add additional layouts and widgets to the layout. (child objects)

Position, Size, Padding and MarginsEx. getLeft(), getHight(), getPadding()

Page 7: Android GUI

Common Layouts

RelativeLayout

LinearLayout

Page 8: Android GUI

Widgets

The visual UI elements to be used on your Application screen.

Includes Buttons, Images, dialog and many other objects.

Interfaces & Classes

Page 9: Android GUI

How To Create a Button

In the java source code

In the XML layout

Page 10: Android GUI

Notifications For a situation where you may need to notify a user

about an event from your application 3 Types

Toast Notification▪ Brief message that comes form the background

Status Bar Notification▪ Background reminders that request the user’s response

Dialog Notification▪ Activity-related notifications, sometimes require an user interaction.

Toast Notification Status Bar Notification Dialog Notification

Page 11: Android GUI

Toast Notification

Initiating a Toast object Initiate toast from the source code

Or by chaining methods

Page 12: Android GUI

Status Bar Notifications How to create a status bar notification:

1. Reference the NotificationManager:

2. Instantiate the Notification:

3. Define the Notification's expanded message and Intent:

4. Pass the Notification to the NotificationManager:

Page 13: Android GUI

Dialog Notifications Types of Dialogs

AlertDialog▪ Can have buttons, selectable items, and text dialog.

ProgressDialog▪ Displays a wheel or progress bar, also supports buttons.

DatePickerDialog▪ Allows user to select a date.

TimePickerDialog▪ Allows user to select a time.

CustomDialogs▪ Create your own dialog to suit your needs.

Examples

Page 14: Android GUI

Creating Menus Allows users to access application functions and

settings. 3 Types of menus

Options Menu▪ Appear when user presses the hard MENU button▪ Two Types▪ Icon Menu▪ Expanded Menu

Context Menu▪ Floating list of menu items, appears after a long-press on an item.

Submenu▪ Floating list of menu items that the user opens by pressing a

menu item in the Options Menu or context menu. Example Menus

Page 15: Android GUI

Source

http://developer.android.com/guide/topics/ui/index.html