ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.

Slides:



Advertisements
Similar presentations
Android Application Development Tutorial. Topics Lecture 6 Overview Programming Tutorial 3: Sending/Receiving SMS Messages.
Advertisements

Chapter 3 – Web Design Tables & Page Layout
Android UserInterfaces Nasrullah Niazi. overView All user interface elements in an Android app are built using View and ViewGroup objects. A View is an.
CE881: Mobile and Social Application Programming Simon M. Lucas Layouts.
Android User Interface
Programming with Android: Widgets and Events Luca Bedogni Marco Di Felice Dipartimento di Scienze dell’Informazione Università di Bologna.
All About Android Introduction to Android 1. Creating a New App “These aren’t the droids we’re looking for.” Obi-wan Kenobi 1. Bring up Eclipse. 2. Click.
 User Interface - Raeha Sandalwala.  Introduction to UI  Layouts  UI Controls  Menus and ‘Toasts’  Notifications  Other interesting UIs ◦ ListView.
Filip Debelić What is it? Android is a mobile operating system (OS) based on the Linux kernel and currently developed by Google Android,
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
User Interface Android Applications. Activities An activity presents a visual user interface. Each activity is given a default window to draw in. The.
Graphical User Interface (GUI) A GUI allows user to interact with a program visually. GUIs are built from GUI components. A GUI component is an object.
By: Jeremy Smith.  Introduction  Droid Draw  Add XML file  Layouts  LinearLayout  RelativeLayout  Objects  Notifications  Toast  Status Bar.
CS378 - Mobile Computing User Interface Basics MIKE!! LOOK HERE FOR intercepting the ListView items:
Android: Layouts David Meredith
Creating Android user interfaces using layouts 1Android user interfaces using layouts.
Better reference the original webpage :
Android development the first app. Andoid vs iOS which is better? Short answer: neither Proponents on both sides For an iOS side, see this article on.
Android Development: Application Layout Richard S. Stansbury 2015.
Introducing the Sudoku Example
Android: versions Note that: Honeycomb (Android v3.0) A tablet-only release Jelly Bean (Android v4.1) Released on July 09, 2012.
CS5103 Software Engineering Lecture 08 Android Development II.
PROG Mobile Java Application Development PROG Mobile Java Application Development Developing Android Apps: Components & Layout.
Favorite Twitter® Searches App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Chapter 2: Simplify! The Android User Interface
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
Chapter 5 Creating User Interfaces GOALS and OBJECTIVES Begin our application by creating our user interface. More than one way to create a user interface.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Android Layouts. Layouts Define the user interface for an activity Layouts are defined in.xml files – within /res/layout folder – different layout can.
Understanding Hello Android 1 CS300. Activity  Similar to a form  Base class for the visual, interactive components of your application  Android API.
Frank Xu Gannon University.  Linear Layout  Relative Layout  Table Layout.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Using Android XML Resources.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
Creating Dialog (ABAP Dynpro) Programs. Slide 2 Introduction All of the ERP systems operate similarly with regard to transactional integrity They all.
Android Boot Camp for Developers Using Java, 3E
UI Resources Layout Resources String Resources Image Resources.
User Interfaces: Part 1 (View Groups and Layouts).
Application Development for mobile Devices
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 2: Simplify! The Android User Interface.
Copyright© Jeffrey Jongko, Ateneo de Manila University Basic Views and Layouts.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Handling View Events. Open the *MainActivity.java* which is the Activity that hosts the layout in "activity_main.xml". The setContentView method inside.
MOBILE COMPUTING D10K-7D02 MC05: Android UI Design Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
1 Android Development Lean and mean introduction Based on a presentation by Mihail L. Sichitiu.
CS378 - Mobile Computing User Interface Basics. User Interface Elements View – Control – ViewGroup Layout Widget (Compound Control) Many pre built Views.
Building User Interfaces Basic Applications
BUILDING A SIMPLE USER INTERFACE. In this lesson, you create a layout in XML that includes a text field and a button. In the next lesson, your app responds.
CHAPTER 4 Fragments ActionBar Menus. Explore how to build applications that use an ActionBar and Fragments Understand the Fragment lifecycle Learn to.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Looping and Multiple Forms.
Android Fragments. Slide 2 Lecture Overview Getting resources and configuration information Conceptualizing the Back Stack Introduction to fragments.
INTRODUCTION TO ANDROID. Slide 2 Introduction I take a top-down approach to describing an application’s anatomy.
Chapter 2: Simplify! The Android User Interface
Java FX: Scene Builder.
Open Handset Alliance.
Mobile Application Development Chapter 3 [Using Eclipse Android Studio for Android Development] IT448-Fall 2017 IT448- Fall2017.
Activities and Intents
Creation of an Android App By Keith Lynn
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
HNDIT2417 Mobile Application Development
CIS 470 Mobile App Development
AWT Components and Containers
Building User Interfaces Basic Applications
Android Developer Fundamentals V2
CIS 470 Mobile App Development
Mobile Programmming Dr. Mohsin Ali Memon.
User Interface Screen Elements
Android Sensor Programming
Presentation transcript:

ANDROID LAYOUTS AND WIDGETS

Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes and other widgets Ways to program event handlers

Slide 3 Android UI Concepts All Android applications have similar user interface elements Some of this has changed from the first phones but that was a long time ago Some of the first devices had a hardware menu button

Slide 4 Android Screen Elements (1) The System bar appears along the top of the screen and contains system and notification icons Toolbars typically appear across the top of the application and can be rendered differently The App bar (action bar) is a special form of toolbar having the one or many of a navigation icon, title, filter, and action icons and menu icons

Slide 5 Android Screen Elements (2) The navigation bar appears along the bottom of the device The remainder of the screen is covered by a layout There are other popup windows and messages that will be discussed later with multiple activities

Slide 6 Android Font Sizes All views have a size Fonts have a size. We can use the following units of measure px – screen pixels in – inches based on the physical screen size mm – millimeters based on the physical screen size pt – 1/72 of an inch based on physical screen size dp or dip – device independent unit based relative to a 160 dpi screen sp – similar to dp but used for font sizes

Slide 7 Gravity Gravity is a way to define which side of the parent an object is anchored android:gravity refers to the gravity of the view’s content (text for example) android:layout_gravity refers to the gravity of the view itself Only works with a linear layout Widgets are anchored along the parent layout center_vertical, center_horiztonal, center

Slide 8 Gravity

Slide 9 Android Layouts (Introduction) Visual elements are built from ViewGroup : These are the different layouts which conning other ViewGroups and other widgets ( LinearLayout, RelativeLayout ) Views are the widgets with which the user interacts ( Button, etc). ViewGroup and View objects are organized into a hierarchy

Slide 10 Android Layouts (Illustration)

Slide 11 Application Components (Layout) There are different types of layouts for a screen (View) Using a LinearLayout, child widgets are aligned horizontally or vertically Using a RelativeLayout child widgets are aligned relative to each other or the parent window There are other layouts not discussed in this section

Slide 12 Application Components (Layout) (1) A layout describes the visual structure for a UI element, such as the UI for an activity It’s an XML document, so you need some familiarity with XML Android provides an XML vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts

Slide 13 Application Components ( LinearLayout ) LinearLayout aligns child objects vertically or horizontally Use the android:orientation attribute to specify the layout direction ( vertical / horizontal ) Scrollbars appear if the window length exceeds the screen length

Slide 14 Application Components ( LinearLayout ) Create multiple nested LinearLayout widgets to nest vertical and horizontal layouts

Slide 15 Application Components ( RelativeLayout ) RelativeLayout aligns objects relative to each other (siblings) Such as: Child A to the left of child B Or align to the parent

Slide 16 Android RelativeLayout (Positioning Child Widgets) Position children relative to each other or the parent By default, all views are drawn at the top left of the layout These properties belong to RelativeLayout.LayoutParams There are many properties but we really only need a few for most layouts

Slide 17 Android RelativeLayout (Positioning Child Widgets) android:layout_alignParentTop If true makes the top edge of this widget match the top edge of the parent android:layout_alignTop Positions the top edge of this view to match the one with the specified resource ID

Slide 18 Android RelativeLayout (Positioning Child Widgets) android:layout_below Positions the top edge of this view below the one with the specified resource id android:layout_toRightOf Positions the left edge of this view to the right of the one with the specified resource id

Slide 19 Introduction to Input Controls TextView operates like a VB TextBox Button operates like a VB button CheckBox operates like a VB check box Etc.. All are configured as XML in a layout file

Slide 20 TextView Control It displays a prompt to the user labelFor attribute contains a reference to the EditText control in which the user enters input text attribute contains the visible text

Slide 21 EditText Control An editable text control similar to a text box android:inputtype defines the allowable input values android:text contains the text Runtime getText and setText method retrieve or set the text, respectively

Slide 22 EditText Control Using getText and setText final EditText txtDemo; txtDemo = (EditText) findViewById(R.id.txtDemo) txtDemo.setText(“Hello”); String s = txtDemo.getText.toString();

Slide 23 Button Control A button has a width and height The button’s text appears in strings.xml As you will see, there are several ways to wire events

Slide 24 CheckBox Control As in most environments, it’s a two-state control that is checked or unchecked The isChecked accessor indicates whether the box is checked or not The setChecked mutator accepts a Boolean argument to set the state of the widget (checked / unchecked)

Slide 25 Handling Events There are different ways to handle events in Android We will discuss a few of them Link XML document to handler

Slide 26 Application Components (Handling a Click – Method 1) When the user clicks a button, the object receives an onClick event which you can handle

Slide 27 Application Components (Handling a Click – Method 2) The event handler can also be declared programmatically using an anonymous class The book uses this technique

Slide 28 Application Components (Handling a Click – Method 3) Using this technique, you create a class that implements the OnClickListener interface When you implement this interface, you must implement the onClick method Call the setOnClickListener for the view passing an instance of the above class

Slide 29 Application Components (Handling a Click – Method 3) x

Slide 30 Application Components (Activities) ( onCreate indicates that we are overriding a base class method It’s an informative annotation Annotations are used to control compiler behavior Similar to.NET attributes

Slide 31 Application Components (Activities) ( onCreate ) super.onCreate calls the base class method Super is roughly equivalent MyBase in VB It typically appears as the first statement in the method

Slide 32 Application Components (Activities) ( onCreate ) setContentView takes one argument – the resource id corresponding to the activity It associates a particular view with the activity The resource is always named R Layout is the layout that you want to use Followed by the resource id of the layout