EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

Similar documents
EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

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

Intents. Your first app assignment

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

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

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

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

EMBEDDED SYSTEMS PROGRAMMING Android Services

Android Programs Day 5

Fragments. Lecture 11


Topics of Discussion

Arrays of Buttons. Inside Android

ANDROID PROGRAMS DAY 3

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

Tip Calculator. xmlns:tools=" android:layout_width="match_parent"

SD Module-1 Android Dvelopment

User Interface Development in Android Applications

ELET4133: Embedded Systems. Topic 15 Sensors

Basic GUI elements - exercises

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

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)

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

M.A.D Assignment # 1


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

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

Chapter 5 Flashing Neon FrameLayout

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

android-espresso #androidespresso

Our First Android Application

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

Vienos veiklos būsena. Theory

StoppUhr. <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="start1"

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

<uses-permission android:name="android.permission.internet"/>

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

COMP4521 EMBEDDED SYSTEMS SOFTWARE

05. RecyclerView and Styles

Mobile Software Development for Android - I397

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

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

Produced by. Mobile Application Development. Eamonn de Leastar

API Guide for Gesture Recognition Engine. Version 2.0

Android - Widgets Tutorial

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

Dynamically Create Admob Banner and Interstitial Ads

Android HelloWorld - Example. Tushar B. Kute,

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

ANDROID USER INTERFACE

EMBEDDED SYSTEMS PROGRAMMING Application Basics

PROGRAMMING APPLICATIONS DECLARATIVE GUIS

Chapter 8 Positioning with Layouts

Lecture 14. Android Application Development

Android CardView Tutorial

Learn about Android Content Providers and SQLite

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

Data Persistence. Chapter 10

Android UI Development

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

Android - JSON Parser Tutorial

MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs

Android Application Development. By : Shibaji Debnath

Notification mechanism

API Guide for Gesture Recognition Engine. Version 1.1

Create a local SQL database hosting a CUSTOMER table. Each customer includes [id, name, phone]. Do the work inside Threads and Asynctasks.

Mobile Software Development for Android - I397

Open Lecture Mobile Programming. Intro to Material Design

Creating a Custom ListView

Action Bar. (c) 2010 Haim Michael. All Rights Reserv ed.

// MainActivity.java ; Noah Spenser; Senior Design; Diabetic Breathalyzer

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

Mobile Computing Fragments

Android Application Development

Text Properties Data Validation Styles/Themes Material Design

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

Tutorial: Setup for Android Development

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

COMP61242: Task /04/18

App Development for Smart Devices. Lec #7: Audio, Video & Telephony Try It Out

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

Android UI: Overview

Simple Currency Converter

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

CS 4330/5390: Mobile Application Development Exam 1

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

Android & iphone. Amir Eibagi. Localization

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

Android Beginners Workshop

使用 TensorFlow 設計矩陣乘法計算並轉移執行在 Android 上 建國科技大學資管系 饒瑞佶 2017/8

<uses-permission android:name="android.permission.internet" />

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

Android Navigation Drawer for Sliding Menu / Sidebar

UI Fragment.

Meniu. Create a project:

Mobile Computing Practice # 2c Android Applications - Interface

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

Transcription:

EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Managing Screen Orientation

ORIENTATIONS Portrait Landscape Reverse portrait Reverse landscape

ON REVERSE PORTRAIT Android: all four orientations are supported; the application screen is rotated by default ios: all four orientations are supported; the application screen is rotated by default, with the exception of the Reverse Portrait orientation Windows Phone: only Portrait, Landscape left and Landscape right ; the application screen is rotated only if the SupportedOrientations property is set to PortraitOrLandscape

THE PROBLEM How to create and manage different UIs for portrait and landscape mode Widgets that are common to both UIs must preserve their state when the orientation changes UIs are specified declaratively Solution: use the facilities provided by the platform s frameworks

THE TIP (1/3)

THE TIP (2/3) In Android it is possible to declaratively define multiple versions of the same UI that match different orientations and screen sizes The different versions must be XML files with the same name but placed in different directories with appropriate qualifiers (they are just suffixes in the name of the directories)

THE TIP (3/3) Default: portrait Landscape For a full list of qualifiers, look up http://developer.android.com/guide/topics/resources/providi ng-resources.html Resources (including layouts) are used automatically by Android as the need arises

CODE (1/5) Source files: PersistenceActivity.java Other resources: layout/main.xml (UI layout, portrait), layout-land/main.xml (UI layout, landscape), values/strings.xml (UI strings)

CODE (2/5) values/strings.xml <resources> <string name="app_name">manageorientation</string> <string name="hello">portrait</string> <string name="hello_land">landscape</string> </resources>

CODE (3/7) layout/main.xml (1/2) <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:gravity="center" android:weightsum="3.0" tools:context="it.unipd.dei.esp1516.manageorientation.mainactivity">

CODE (4/7) layout/main.xml (2/2) <ToggleButton android:text="togglebutton" android:id="@+id/togglebutton1" android:layout_width="wrap_content" android:layout_height="wrap_content"> </ToggleButton> <TextView android:text="@string/hello" android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="0dp" android:layout_weight="1.5" android:gravity="center"> </TextView> <ToggleButton android:text="togglebutton" android:id="@+id/togglebutton2" android:layout_width="wrap_content" android:layout_height="wrap_content"> </ToggleButton> </LinearLayout>

CODE (5/7) layout-land/main.xml (1/2) <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:gravity="center" android:weightsum="3.0" tools:context="it.unipd.dei.esp1516.manageorientation.mainactivity">

CODE (6/7) layout-land/main.xml (2/2) <ToggleButton android:text="togglebutton" android:id="@+id/togglebutton1" android:layout_width="wrap_content" android:layout_height="wrap_content"> </ToggleButton> <TextView android:text="@string/hello_land" android:id="@+id/textview1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1.5" android:gravity="center"> </TextView> <ToggleButton android:text="togglebutton" android:id="@+id/togglebutton2" android:layout_width="wrap_content" android:layout_height="wrap_content"> </ToggleButton> </LinearLayout>

CODE (7/7) MainActivity.java package it.unipd.dei.esp1516.manageorientation; import android.support.v7.app.appcompatactivity; import android.os.bundle; public class MainActivity extends AppCompatActivity { /** Called when the activity is first created. */ @Override protected void oncreate(bundle savedinstancestate) { // The ToggleButton's auto-save and auto-restore their instance // state using the savedinstancestate Bundle. // Since corresponding ToggleButton's have the same name in both // layouts, their state is correctly auto-managed: there is no need // to write any custom code super.oncreate(savedinstancestate); setcontentview(r.layout.main); } }

LAST MODIFIED: MARCH 26, 2017 COPYRIGHT HOLDER: CARLO FANTOZZI (FANTOZZI@DEI.UNIPD.IT) LICENSE: CREATIVE COMMONS ATTRIBUTION SHARE-ALIKE 3.0