Mobile Application (Design and) Development

Similar documents
Programming of Mobile Services, Spring 2012

Graphics Support in Android

CS260 Intro to Java & Android 09.AndroidAdvUI (Part I)

Mastering Android Drawables

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

Learning Android Canvas

package import import import import import import import public class extends public void super new this class extends public super public void new

Android HelloWorld - Example. Tushar B. Kute,

Arrays of Buttons. Inside Android

Custom Views in Android Tutorial

GATAV 5. Animations Using a Game Loop

INTRODUCTION TO ANDROID

CS371m - Mobile Computing. 2D Graphics A Crash Course in Using (Android) 2D Graphics Libraries

Practical 1.ListView example

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

CMSC434. Introduction to Human-Computer Interaction. Week 10 Lecture 17 Mar 31, 2016 Engineering Interfaces III. Jon

Intents. Your first app assignment

Software Practice 3 Before we start Today s lecture Today s Task Team organization

Embedded Systems Programming - PA8001

Android Development Tutorial

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2

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

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

Have a development environment in 256 or 255 Be familiar with the application lifecycle

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

COMP4521 EMBEDDED SYSTEMS SOFTWARE

Android Apps Development for Mobile Game Lesson Create a simple paint brush that allows user to draw something (Page 11 13)

Android UI Development

ANDROID (4) 2D Graphics and Animation, Handling Screen Rotation. Marek Piasecki

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

Basic GUI elements - exercises

Android Application Development

Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB)

Mobile User Interfaces

Introduction to Mobile Application Development Using Android Week Four Video Lectures

Project Report Group 4

05. RecyclerView and Styles

OPTIMIZING ANDROID UI PRO TIPS FOR CREATING SMOOTH AND RESPONSIVE APPS

University of Stirling Computing Science Telecommunications Systems and Services CSCU9YH: Android Practical 1 Hello World

Mobile Computing Practice # 2c Android Applications - Interface

BSCS 514- Computer Graphics. Course Supervisor : Dr. Humera Tariq Hands on Lab Sessions: Mr. Faraz Naqvi

A Crash Course to Android Mobile Platform

Bouncing and Actor Class Directions Part 2: Drawing Graphics, Adding Touch Event Data, and Adding Accelerometer

Chapter 5 Flashing Neon FrameLayout

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

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Lecture 14. Android Application Development

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)

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

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

Programming Concepts and Skills. Creating an Android Project

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

MotionEvents Touch Handling Gestures

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

User Interface Development. CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr.

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Terms: MediaPlayer, VideoView, MediaController,

EECS 1001 and EECS 1030M, lab 01 conflict

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

Mobile Image Processing

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Mobile Programming Lecture 1. Getting Started

Real-Time Embedded Systems

Starting Another Activity Preferences

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

Database Development In Android Applications

Introduction to Mobile Application Development Using Android Week Three Video Lectures

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

Lecture 2 Android SDK

Android Basics. Android UI Architecture. Android UI 1

Android. Soft Keyboard Graphics and Media

Android Application Development. By : Shibaji Debnath

1 카메라 1.1 제어절차 1.2 관련주요메서드 1.3 제작철차 서피스뷰를생성하고이를제어하는서피스홀더객체를참조해야함. 매니페스트에퍼미션을지정해야한다.

Screen Slides. The Android Studio wizard adds a TextView to the fragment1.xml layout file and the necessary code to Fragment1.java.

Android development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2.

Thread. A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables.

Embedded Systems Programming - PA8001

Understand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml

Create new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings.

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.

Android Workshop: Model View Controller ( MVC):

Android UI DateBasics

Introduction to Android Development

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

Produced by. Mobile Application Development. Eamonn de Leastar

CS 403X Mobile and Ubiquitous Computing Lecture 3: Introduction to Android Programming Emmanuel Agu

CSE1720. Objectives for this class meeting 2/10/2014. Cover 2D Graphics topic: displaying images. Timer class, a basic ActionListener

android-espresso #androidespresso

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

IEMS 5722 Mobile Network Programming and Distributed Server Architecture

App Development for Smart Devices. Lec #18: Advanced Topics

Spring Lecture 7 Lecturer: Omid Jafarinezhad


Solving an Android Threading Problem

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

TextView. A label is called a TextView. TextViews are typically used to display a caption TextViews are not editable, therefore they take no input

MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs

Assignment #4 Minesweeper

Transcription:

Mobile Application (Design and) Development 7 th class Prof. Stephen Intille s.intille@neu.edu Northeastern University 1

Q&A Workspace setup in lab. Anyone try it? Anyone looking for a partner? Boggle various strategies Buttons, swiping, 2d graphics, pause button, etc. Northeastern University 2

Today Overview of 2d graphics (part 1) Looking at graphics in Sudoku code Two design papers Pixel Perfect Code: How to Marry Interaction and Visual Design the Android Way Presenter: Kevin Rottman FIRST Else smartphone hands-on demo from Mobile World Congress 2010 Presenter: Trevor Sontag Northeastern University 3

Schedule Sunday: programming assignment 2 due Monday: guest lecture Jason Nawyn Tuesday: in-class paper prototyping (bring what you need) Wednesday: guest lecture Fahd Albinali Preliminary paper prototype design due Thursday: location and sensing Sunday: Programming assignment 3 due Northeastern University 4

Graphics in Android Custom 2D graphics library OpenGL ES 1.0 for high performance 3D graphics Most common 2d graphics: android.graphics.drawable From ADG: When starting a project, it's important to consider exactly what your graphical demands will be Northeastern University 5

2d graphics option #1 Draw into a View object from your layout Drawing/animation of graphics handled by system's normal View hierarchy drawing process You simply define graphics to go inside View Call invalidate(); handle ondraw() callback Best for drawing graphics that are not part of a performance-intensive game Good for displaying static graphics or displaying animations within an otherwise static app Northeastern University 6

2d graphics option #2 Draw your graphics directly to a Canvas You call the appropriate class's draw() method (passing it your Canvas), or one of the Canvas draw...() methods You are in control of animation Best if you application needs to regularly redraw itself Fast animation games must use this (or 3d) Can use separate thread, manage a SurfaceView, and perform draws to the Canvas as fast as your thread is capable Northeastern University 7

2d graphics Drawable Abstraction for something that can be drawn Types BitmapDrawable ShapeDrawable PictureDrawable LayerDrawable Others... Northeastern University 8

Drawable Three ways to define and instantiate: Using an image saved in your project resources Using an XML file that defines the Drawable properties Using the normal class constructors Northeastern University 9

(E.g., my_image.png is referenced as my_image). Creating from resources Easy Image types: PNG (preferred) JPG (acceptable) GIF (discouraged) Add your file to the res/drawable/ directory E.g., my_image.png is referenced as my_image Northeastern University 10

ImageView using resources LinearLayout mlinearlayout; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // Create a LinearLayout in which to add the ImageView mlinearlayout = new LinearLayout(this); // Instantiate an ImageView and define its properties ImageView i = new ImageView(this); i.setimageresource(r.drawable.my_image); // set the ImageView bounds to match the Drawable's dimensions i.setadjustviewbounds(true i.setlayoutparams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); } // Add the ImageView to the layout and set the layout as the content view mlinearlayout.addview(i); setcontentview(mlinearlayout); Northeastern University 11

Handling image res as drawable Resources res = mcontext.getresources(); Drawable myimage = res.getdrawable(r.drawable.my_image); Add a resource Drawable to an ImageView in the XML layout: <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:tint="#55ff0000" android:src="@drawable/my_image"/> Northeastern University 12

Creating from resource XML res/drawable/expand_collapse.xml: <transition xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/image_expand"> <item android:drawable="@drawable/image_collapse"> </transition> Resources res = mcontext.getresources(); TransitionDrawable transition = (TransitionDrawable) res.getdrawable(r.drawable.expand_collapse); ImageView image = (ImageView) findviewbyid(r.id.toggle_image); image.setimagedrawable(transition); Run forward for 1s: transition.starttransition(1000); Northeastern University 13

ShapeDrawable public class CustomDrawableView extends View { private ShapeDrawable mdrawable; public CustomDrawableView(Context context) { super(context); int x = 10; int y = 10; int width = 300; int height = 50; } mdrawable = new ShapeDrawable(new OvalShape()); mdrawable.getpaint().setcolor(0xff74ac23); mdrawable.setbounds(x, y, x + width, y + height); } protected void ondraw(canvas canvas) { mdrawable.draw(canvas); } Northeastern University 14

ShapeDrawable CustomDrawableView mcustomdrawableview; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); mcustomdrawableview = new CustomDrawableView(this); } setcontentview(mcustomdrawableview); Northeastern University 15

Nine-patch Top image shows pixels that will be replicated for stretching Bottom image identifies the region in which the contents of the View are allowed. If the contents don't fit in this region, then the image will be stretched so that they do. Northeastern University 16

Draw nine-patch tool VERY useful Northeastern University 17

Adding drawable to button <Button id="@+id/tiny" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparenttop="true" android:layout_centerinparent="true" android:text="tiny" android:textsize="8sp" android:background="@drawable/my_button_background"/> <Button id="@+id/big" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_centerinparent="true" android:text="biiiiiiig text!" android:textsize="30sp" android:background="@drawable/my_button_background"/> Northeastern University 18

What is a canvas? Interface to drawing surface Holds draw calls Actual drawing uses a Bitmap put onto the window You can... Use OnDraw() (Canvas provided) Get canvas (using SurfaceView objects) Create new canvas... Northeastern University 19

Create new canvas Bitmap b = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); You can then carry to another Canvas using a Canvas.drawBitmap(Bitmap,...) method Best to draw final graphics via Canvas from View.onDraw() or SurfaceHolder.lockCanvas() Northeastern University 20

Using View.onDraw() Android only calls ondraw() as necessary Use invalidate() to indicate a redraw is necessary Better: Northeastern University 21

Using View.onDraw() Android only calls ondraw() as necessary Use invalidate() to indicate a redraw is necessary Not immediate Better: Northeastern University 22

Using View.onDraw() Use Canvas and all Canvas.draw...() methods After ondraw() finishes, Android does the work to draw actual Bitmap (Snake example in API) Northeastern University 23

Using SurfaceView Dedicated drawing surface within the View hierarchy Offer a drawing surface to a secondary thread (decouple from UI/View hierarchy) (Lunar Lander example in API) Northeastern University 24

Sudoku Looking at/questions about code... Northeastern University 25

Readings Northeastern University 26