Mobile Software Development for Android - I397

Similar documents
Chapter 8 Positioning with Layouts

Android UI: Overview

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

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

ANDROID USER INTERFACE

Sizing and Positioning

Android Layout Types

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

Introductory Android Development

Laying Out Controls in Containers

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

Comparative Study on Layout and Drawable Resource Behavior in Android for Supporting Multi Screen

A view is a widget that has an appearance on screen. A view derives from the base class android.view.view.

Android UI Development

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

Topics of Discussion

User Interface Development in Android Applications

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

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

Android Basics. Android UI Architecture. Android UI 1

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

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

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

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

Graphical User Interfaces

UI (User Interface) overview Supporting Multiple Screens Touch events and listeners

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

CS378 -Mobile Computing. User Interface Basics

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

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

Android Application Development

Layout and Containers

South Africa

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

Praktikum Entwicklung Mediensysteme. Implementing a User Interface

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

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

Charlie Collins Michael Galpin Matthias Käppler IN PRACTICE. Includes 91 Techniques SAMPLE CHAPTER MANNING

ANDROID APPS DEVELOPMENT FOR MOBILE GAME

Adaptation of materials: dr Tomasz Xięski. Based on presentations made available by Victor Matos, Cleveland State University.

Mobile Application Development Android

Android UI DateBasics

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


Fragment Example Create the following files and test the application on emulator or device.

Chapter 5 Flashing Neon FrameLayout

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

Multiple devices. Use wrap_content and match_parent Use RelativeLayout/ConstraintLayout Use configuration qualifiers

Creating a User Interface

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

CS371m - Mobile Computing. User Interface Basics

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

Tłumaczenie i adaptacja materiałów: dr Tomasz Xięski. Na podstawie prezentacji udostępnionych przez Victor Matos, Cleveland State University.

Chapter 2 Welcome App

Lesson 4. Graphical User Interfaces. Graphical User Interfaces... 3

TPCT s College of Engineering, Osmanabad. Laboratory Manual SDL-II. Mobile Application Development (Android) For. Third Year Students (CSE)

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

Create Parent Activity and pass its information to Child Activity using Intents.

Mobile Technologies JULY 24, 2018

Created By: Keith Acosta Instructor: Wei Zhong Courses: Senior Seminar Cryptography

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

Mobile Computing Practice # 2c Android Applications - Interface

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

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:

TextView Control. EditText Control. TextView Attributes. android:id - This is the ID which uniquely identifies the control.

Basic GUI elements - exercises

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

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

CS 4330/5390: Mobile Application Development Exam 1

Tablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time

Text Properties Data Validation Styles/Themes Material Design

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

GUI Design for Android Applications

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

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

Programming Android UI. J. Serrat Software Design December 2017

Android HelloWorld - Example. Tushar B. Kute,

Intents. Your first app assignment

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

ConstraintLayouts in Android

Intents, Intent Filters, and Invoking Activities: Part I: Using Class Name

Mobile Software Development for Android - I397

Adapter.

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

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

ANDROID PROGRAMS DAY 3

Android. YÉÇàá. Victor Matos Cleveland State University

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

Android DP SDK Integration Guide

Mobile and Ubiquitous Computing: Android Programming (part 3)

Mobile User Interfaces

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

Lecture 14. Android Application Development

Mobile Programming Lecture 5. Composite Views, Activities, Intents and Filters

Notification mechanism

Basic UI elements: Android Buttons (Basics) Marco Ronchetti Università degli Studi di Trento

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

CSE 660 Lab 7. Submitted by: Arumugam Thendramil Pavai. 1)Simple Remote Calculator. Server is created using ServerSocket class of java. Server.

M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126

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

Transcription:

1 Mobile Software Development for Android - I397 IT COLLEGE, ANDRES KÄVER, 2015-2016 EMAIL: AKAVER@ITCOLLEGE.EE WEB: HTTP://ENOS.ITCOLLEGE.EE/~AKAVER/2015-2016/DISTANCE/ANDROID SKYPE: AKAVER

Layout fundamentals 2 Basic layout Linear Relative Frame Table Basic attributes Size Margin vs padding Gravity

Layout 3 Defines declaritively visual structure for app Takes into consideration screen properties size pixel density System calculates sizes and position for all UI elements

Layout 4

Layout - LinearLayout 5 Arranges its children in single direction Orientation= horizontal Orientation= vertical <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> ui elements </LinearLayout>

Layout - RelativeLayout 6 Elements are arranged relative to Parent UI element Sibling UI element <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <EditText android:layout_width="wrap_content" android:layout_height="200px" android:inputtype="textmultiline" android:ems="10" android:id="@+id/edittext2" android:layout_alignparenttop="true" android:layout_alignparentstart="true" android:layout_alignparentend="true" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="new Button" android:id="@+id/button4" android:layout_below="@+id/edittext2" android:layout_alignparentend="true" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="new Button" android:id="@+id/button5" android:layout_alignbottom="@+id/button4" android:layout_tostartof="@+id/button4" /> </RelativeLayout>

Layout - FrameLayout 7 Allows to put child views on top of each other Specify order Layout gravity for positioning

Layout - TableLayout 8 Rows and Columns Like Linear vertical nesting Linear horizontal Columns are aligned (by the widest in all the rows)

Basic attributes 9 Used across all layouts Size Margin vs padding Gravity

Size 10 Match_parent Wrap_content Use background tint for visual cues android:background="#ff0000" Xxxdp Density-independent pixel px = dp * density density = bucket(dpi/160) <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> android:layout_width="match_parent" android:layout_height="wrap_content" android:text="new Text" android:id="@+id/textview2" /> </LinearLayout>

Size - dp 11

Margin vs padding 12

Margin vs padding 13 No margin android:padding android:layout_margin layout_xxx prefix deals with data from outside the view padding inside the view

Gravity 14 Android:layout_gravity Position of the view, regarding its parent Android:gravity Position of the content inside the view

Gravity 15 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> android:layout_width="160dp" android:layout_height="160dp" android:gravity="center_horizontal" android:background="#ff0000" android:text="new Text" android:id="@+id/textview2" /> </LinearLayout> <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> android:layout_width="160dp" android:layout_height="160dp" android:layout_gravity="center_horizontal" android:background="#ff0000" android:text="new Text" android:id="@+id/textview2" /> </LinearLayout>

Gravity 16 Can be mixed and combined <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> android:layout_width="160dp" android:layout_height="160dp" android:gravity="center_horizontal bottom" android:layout_gravity="right" android:background="#ff0000" android:text="new Text" android:id="@+id/textview2" /> </LinearLayout>

LinearLayout 17 What is LinearLayout? Gravity Weight Nested layout

LinearLayout 18

LinearLayout - Gravity 19

LinearLayout - Gravity 20

LinearLayout - Weight 21 Additional way to specify dimensions (match_parent, wrap_content, xxxdp) Adds weights together Width is based on ratios (1+1=2 => ½ and ½) Can be mixed every way

LinearLayout - weightsum 22 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_horizontal" android:weightsum="4"> android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:background="#ff0000" android:text="left side" android:id="@+id/textview2" /> android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:background="#00ff00" android:text="right side" android:id="@+id/textview3" /> </LinearLayout

LinearLayout - nested 23 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/edittext3" /> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="right"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="cancel" android:id="@+id/button6"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="ok" android:id="@+id/button7" /> </LinearLayout> </LinearLayout>

RelativeLayout 24 What it is? Relative Positioning Relative Alignement Missing Views

RelativeLayout 25

RelativeLayout 26 Relative Position Alignment To Parent Sibling

RelativeLayout - attributes 27

RelativeLayout 28 Uses default parameters Top Left <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <EditText android:id="@+id/edittext2" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputtype="textmultiline" /> </RelativeLayout>

RelativeLayout 29 No positions given Views are on top of each other <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <EditText android:id="@+id/edittext2" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputtype="textmultiline" /> <Button android:id="@+id/button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="new Button" /> </RelativeLayout>

RelativeLayout 30 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <EditText android:id="@+id/edittextgreeting" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputtype="textmultiline" /> <Button android:id="@+id/buttonok" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/edittextgreeting" android:layout_alignparentright="true" android:text="ok" /> </RelativeLayout>

RelativeLayout 31 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <EditText android:id="@+id/edittextgreeting" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputtype="textmultiline" /> <Button android:id="@+id/buttonok" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/edittextgreeting" android:layout_alignparentright="true" android:text="ok" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toleftof="@id/buttonok" android:text="cancel" android:id="@+id/buttoncancel" /> </RelativeLayout>

RelativeLayout 32 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <EditText android:id="@+id/edittextgreeting" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputtype="textmultiline" /> <Button android:id="@+id/buttonok" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/edittextgreeting" android:layout_alignparentright="true" android:text="ok" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toleftof="@id/buttonok" android:layout_below="@id/edittextgreeting" android:text="cancel" android:id="@+id/buttoncancel" /> </RelativeLayout>

RelativeLayout 33 Relative to sibling Relative to sibling Layout_above Layout_alignTop Layout_below Layout_alignBottom Layout_toLeftOf Layout_alignLeft Layout_toRightOf Layout_alignRight Layout_alignBaseline

RelativeLayout 34 Relative to parent Layout_alignParentTop Layout_alignParentBottom Layout_alignParentLeft Layout_alignParentRight Layout_centerHorizontal Layout_centerVertical Layout_centerInParent

RelativeLayout Missing views 35 Visibility= invisible View is still there, just invisible Placement of element is not changed Visibility= gone UI layout changes, view is really not there Defaults apply (top left) When changing visibility programmatically Layout_alignWithParentIfMissing= true

FrameLayout 36 Allows to put views on top of each other Position child wiews with layout_gravity Layout_margin Usually used for placing images on top of other images Think of PictureFrame You can save one view by using on FrameLayout definition Android:foreground= @drawable/somepicture Control scaling of foreground (default is fill) Android:foregroundGravity= top left

TableLayout 37 What is TableLayout Spanning and skipping Shrinking, stretching and collapsing

TableLayout 38 Specialized linear layout Rows Columns TableRow is always Layout_width= match_parent Layout_height= wrap_content

TableLayout 39 <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <TableRow> android:background="#ff0000" android:text="first" /> android:background="#00ff00" android:text="second long" /> android:background="#0000ff" android:text="third0" /> </TableRow> <TableRow> android:background="#ff0000" android:text="first long" /> android:background="#00ff00" android:text="second" /> android:background="#0000ff" android:text="third" /> </TableRow> </TableLayout>

TableLayout skipping 40 <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <TableRow> android:background="#ffff00" android:text="very long title" android:layout_column="1"/> </TableRow> <TableRow> android:background="#ff0000" android:text="first" /> android:background="#00ff00" android:text="second long" /> android:background="#0000ff" android:text="third0" /> </TableRow> <TableRow> android:background="#ff0000" android:text="first long" /> android:background="#00ff00" android:text="second" /> android:background="#0000ff" android:text="third" /> </TableRow> </TableLayout>

TableLayout spanning 41 <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <TableRow> android:background="#ffff00" android:text="very long title" android:layout_column="1" android:layout_span="2"/> </TableRow> <TableRow> android:background="#ff0000" android:text="first" /> android:background="#00ff00" android:text="second long" /> android:background="#0000ff" android:text="third0" /> </TableRow> <TableRow> android:background="#ff0000" android:text="first long" /> android:background="#00ff00" android:text="second" /> android:background="#0000ff" android:text="third" /> </TableRow> </TableLayout>

TableLayout shrinking, stretching, collapsing 42

TableLayout shrinking 43 <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:shrinkcolumns="1"> <TableRow> android:layout_column="0" android:layout_marginleft="4dp" android:layout_marginright="4dp" android:layout_span="3" android:background="#ffff00" android:text="very long title" /> </TableRow> <TableRow> android:layout_height="match_parent" android:layout_marginleft="4dp" android:layout_marginright="4dp" android:background="#ff0000" android:text="first" /> android:layout_height="match_parent" android:layout_marginright="4dp" android:background="#00ff00" android:singleline="false" android:text="second long long long long long long long long long long long end" /> android:layout_height="match_parent" android:layout_marginright="4dp" android:background="#0000ff" android:text="third0" /> </TableRow> </TableLayout>

TableLayout stretching 44 <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:shrinkcolumns="1" android:stretchcolumns="*"> <TableRow> android:layout_column="0" android:layout_marginleft="4dp" android:layout_marginright="4dp" android:layout_span="3" android:background="#ffff00" android:text="very long title" /> </TableRow> <TableRow> android:layout_height="match_parent" android:layout_marginleft="4dp" android:layout_marginright="4dp" android:background="#ff0000" android:text="first" /> android:layout_height="match_parent" android:layout_marginright="4dp" android:background="#00ff00" android:singleline="false" android:text="second long long long long long long long long long long long end" /> android:layout_height="match_parent" android:layout_marginright="4dp" android:background="#0000ff" android:text="third0" /> </TableRow> </TableLayout>

TableLayout collapsing 45 Android:collapseColumns= * * 0 1,2,4 Same as visibility= gone

Varia - performance 46

Varia Hierarchy Viewer 47 ViewServer Download ViewServer.java from https://github.com/romainguy/viewserver Add INTERNET permission Enable ViewServer in your activity

Varia Hierarchy Viewer 48 Launch Android Device Monitor Window -> Open Perspective -> Hierarchy View Select your running app from tree Click the icon Load the view hierarchy into the tree view