EECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University. Overview (Review)

Similar documents
EECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

User Interface: Layout. Asst. Prof. Dr. Kanda Runapongsa Saikaew Computer Engineering Khon Kaen University

CS260 Intro to Java & Android 05.Android UI(Part I)

CS260 Intro to Java & Android 05.Android UI(Part I)

Hello World. Lesson 1. Android Developer Fundamentals. Android Developer Fundamentals. Layouts, and. NonCommercial

Programming with Android: Introduction. Layouts. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Android Application Development

Praktikum Entwicklung Mediensysteme. Implementing a User Interface

Overview. What are layouts Creating and using layouts Common layouts and examples Layout parameters Types of views Event listeners

Graphical User Interfaces

ListView (link) An ordered collection of selectable choices. key attributes in XML:

CS 4518 Mobile and Ubiquitous Computing Lecture 5: Data-Driven Views and Android Components Emmanuel Agu

Android UI Development

South Africa

Building User Interface for Android Mobile Applications II

Agenda. Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen

CS371m - Mobile Computing. User Interface Basics

Adapter.

ANDROID USER INTERFACE

Mobile Software Development for Android - I397

Android UI: Overview

CS378 -Mobile Computing. User Interface Basics

GUI Widget. Lecture6

Mobile Application Development Android

Programming with Android: Introduction. Layouts. Luca Bedogni. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna

Chapter 8 Positioning with Layouts

Creating a Custom ListView

Topics of Discussion

Android UI DateBasics

Lab 1 - Setting up the User s Profile UI

Android Basics. Android UI Architecture. Android UI 1

MOBILE COMPUTING 1/20/18. How many of you. CSE 40814/60814 Spring have implemented a command-line user interface?

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

Programming Android UI. J. Serrat Software Design December 2017

Developing Android Applications Introduction to Software Engineering Fall Updated 1st November 2015

The World of List View. Romain Guy and Adam Powell May 19, 2010

ANDROID APPS DEVELOPMENT FOR MOBILE GAME

CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

Android Programming Lecture 2 9/7/2011

Mobile User Interfaces

When programming in groups of people, it s essential to version the code. One of the most popular versioning tools is git. Some benefits of git are:

MAD ASSIGNMENT NO 2. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

Sizing and Positioning

User Interface Development in Android Applications

07. Menu and Dialog Box. DKU-MUST Mobile ICT Education Center

Android Specifics. Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9)

Mobile Computing Practice # 2a Android Applications - Interface

Android Programming in Bluetooth Cochlea Group

Stanislav Rost CSAIL, MIT

Let s take a display of HTC Desire smartphone as an example. Screen size = 3.7 inches, resolution = 800x480 pixels.

Android Layout Types

Mobile Programming Lecture 1. Getting Started

CS 4518 Mobile and Ubiquitous Computing Lecture 2: Introduction to Android Programming. Emmanuel Agu

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

ListView Containers. Resources. Creating a ListView

Beginning Android 4 Application Development

Chapter 5 Flashing Neon FrameLayout

CS 528 Mobile and Ubiquitous Computing Lecture 2a: Introduction to Android Programming. Emmanuel Agu

LECTURE 08 UI AND EVENT HANDLING

Android Application Development 101. Jason Chen Google I/O 2008

CS371m - Mobile Computing. More UI Navigation, Fragments, and App / Action Bars

Getting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering

Activities and Fragments

Creating a User Interface

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

Upon completion of the second part of the lab the students will have:

CS371m - Mobile Computing. More UI Action Bar, Navigation, and Fragments

Programming with Android: Layouts, Widgets and Events. Dipartimento di Scienze dell Informazione Università di Bologna

CHAPTER 4. Fragments ActionBar Menus

Fragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment

Text Properties Data Validation Styles/Themes Material Design

INTRODUCTION COS MOBILE DEVELOPMENT WHAT IS ANDROID CORE OS. 6-Android Basics.key - February 21, Linux-based.

Developing Android Applications

05. RecyclerView and Styles

CS 528 Mobile and Ubiquitous Computing Lecture 2: Intro to Android Programming Emmanuel Agu

Homework 3 - Dumb Notes

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

Mobile Programming Lecture 2. Layouts, Widgets, Toasts, and Event Handling

04. Learn the basic widget. DKU-MUST Mobile ICT Education Center

Figure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard.

The Internet. CS 2046 Mobile Application Development Fall Jeff Davidson CS 2046

Starting Another Activity Preferences

Android Programming - Jelly Bean

COMP4521 EMBEDDED SYSTEMS SOFTWARE

Practical 1.ListView example

Announcements. Android: n-puzzle Walkthrough. Tommy MacWilliam. Dynamic GUIs. ListViews. Bitmaps. Gameplay. Saving State. Menus

Required Core Java for Android application development

CS 528 Mobile and Ubiquitous Computing Lecture 2a: Android UI Design in XML + Examples. Emmanuel Agu

GUI Design for Android Applications

Android Programming (5 Days)

Computer Science E-76 Building Mobile Applications

Android for Ubiquitous Computing Researchers. Andrew Rice University of Cambridge 17-Sep-2011

Widget Toolkits CS MVC

android:orientation="horizontal" android:layout_margintop="30dp"> <Button android:text="button2"

MC Android Programming

Custom Views in Android Tutorial

Transcription:

EECS 4443 Mobile User Interfaces More About Layouts Scott MacKenzie York University Overview (Review) A layout defines the visual structure for a user interface, such as the UI for an activity or app widget Two ways to declare a layout: 1. XML vocabulary. Android provides a straightforward XML vocabulary that organizes the View classes and subclasses, such as those for widgets and layouts. 2. Java code. Instantiate layout elements at runtime. Create and configure View and ViewGroup objects programmatically. 2 1

XML advantage: XML vs. Code Better separation of the presentation of an application from the code that controls its behaviour UI descriptions are external to the application code (simplifies modifications, promotes re use) Easier to visualize the UI structure Easier to debug 3 XML (main.xml) Demo Android 4 2

XML (main.xml) Demo Android Elements Attributes 5 XML main.xml ID Attribute @ The string is expanded as an XML resource + Anew resource to create and add to R.java Code DemoAndroidActivity.java gen R.java 6 3

Load the XML Resource DemoAndroidActivity.java 7 Layout Parameters (1) Layout attributes take the form layout_something Define layout parameters for the views in the view group Parent class ViewGroup.LayoutParams All ViewGroup classes implement a nested class that extends ViewGroup.LayoutParams Examples: LinearLayout LinearLayout.LayoutParams RelativeLayout RelativeLayout.LayoutParams Next slide 8 4

Layout Parameters (2) 9 Common Layouts 10 5

LinearLayout (1) Demo Android 11 LinearLayout (2) Supports Layout Weight for child views Weights assign importance to views Sets relative space a view occupies Larger weight (e.g., 3 ) more space Smaller weight (e.g., 1 ) less space Default is 0 (space provided as necessary) Specified weights will fill available space in proportion to the values Example (next slide) 12 6

LinearLayout (3) Demo Scale main.xml <LinearLayout... > <TextView android:layout_width="fill_parent android:layout_height="wrap_content.../> PaintPanel height fills available space <...PaintPanel android:layout_width="fill_parent android:layout_height="0dp android:layout_weight="1".../> <LinearLayout android:layout_width="fill_parent android:layout_height="wrap_content android:orientation="horizontal"...>... </LinearLayout> </LinearLayout> 13 RelativeLayout (1) Demo Layout 14 7

RelativeLayout (2) layout-land/main.xml edittext1 <RelativeLayout...> <EditText android:id="@+id/edittext1 android:layout_alignparenttop="true.../> button1 button2 <Button android:id="@+id/button1 android:layout_alignleft="@id/edittext1 android:layout_below="@id/edittext1.../> <Button android:id="@+id/button2" android:layout_below="@id/edittext1" android:layout_torightof="@id/button1.../>... </RelativeLayout> 15 Building Layouts With Adapters If The layout is dynamic (not pre determined) Then Use a layout that subclasses AdapterView to populate the layout with views at runtime (e.g., ListView, GridView) AdapterView Uses an Adapter to bind data to its layout Behaves as a middle man between the data source and the AdapterView layout The Adapter retrieves the data (from a source such as an array) and converts each entry into a view that is added into the AdapterView layout 16 8

ListView Demo ListView 17 GridView Demo GridView 18 9

Filling An Adapter View With Data Populate an AdapterView (e.g., ListView) by binding the AdapterView instance to an Adapter The Adapter retrieves data from an external source and creates a View for each data entry Don t use Adapter directly Do use a subclass of Adapter Examples: ArrayAdapter (next slide) CursorAdapter (no demo yet) 19 ArrayAdapter Used if the data source is an array By default ArrayAdapter creates a view for each array item by calling tostring() on each item and placing the contents in a TextView Or If you want an ImageView (instead of a TextView) Extend ArrayAdapter and override getview to return an ImageView Examples: Demo ListView, Demo GridView 20 10

Homework For the demo programs in these slides Download Import into Android projects Run on your Android device (use USB debugging mode) Read APIs (and links within) Study code 21 Thank You 22 11