Android Layout Basics Topics

Slides:



Advertisements
Similar presentations
Introduction to HTML & CSS
Advertisements

Rajab Davudov. What is a Layout ? A type of resource that defines what is drawn on the screen. A type of View class whose primary purpose is to organize.
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.
INTRODUCTION TO HYPERTEXT MARKUP LANGUAGE 1. Outline  Introduction  Markup Languages  Editing HTML  Common Tags  Headers  Text Styling  Linking.
Chapter 4 Marking Up With Html: A Hypertext Markup Language Primer.
Create a Web Site with Frames
Creating Android user interfaces using layouts 1Android user interfaces using layouts.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 9: Customize! Navigating with a Master/Detail.
Chapter 4 Fluency with Information Technology L. Snyder Marking Up With HTML: A Hypertext Markup Language Primer.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Fluency with Information Technology Third Edition by Lawrence Snyder Chapter.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Modify Android Objects Using.
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.
Chapter 2: Simplify! The Android User Interface
Android Layouts. Layouts Define the user interface for an activity Layouts are defined in.xml files – within /res/layout folder – different layout can.
ANDROID – INTERFACE AND LAYOUT L. Grewe. Interfaces: Two Alternatives Code or XML  You have two ways you can create the interface(s) of your Application.
Understanding Hello Android 1 CS300. Activity  Similar to a form  Base class for the visual, interactive components of your application  Android API.
HTML 4 Foundation Level Course HyperText Markup Language Most common language used in creating Web documents. You can use HTML to create cross-platform.
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.
Android Boot Camp for Developers Using Java, 3E
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.
HTML: Hyptertext Markup Language Doman’s Sections.
Tutorial 8 Designing a Web Site with Frames. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore the uses of frames.
Introducing Web Tables. Tables for tabulating items  Better looking  More flexibility  More efficient to explain information than plain text.
Copyright (c) 2004 Prentice-Hall. All rights reserved. 1 Committed to Shaping the Next Generation of IT Experts. Adding Graphical Elements Essentials for.
ANDROID – DRAWING IMAGES – SIMPLE EXAMPLE IN INTERFACE AND EVENT HANDLING L. Grewe.
MOBILE COMPUTING D10K-7D02 MC04: Layouts Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran.
Android View Stuff. TextViews Display text Display images???
1 Mobile Computing Handling Different Display Sizes Copyright 2015 by Janson Industries.
1 Android Development Lean and mean introduction Based on a presentation by Mihail L. Sichitiu.
What is HTML? HTML is a language for describing web pages. HTML stands for Hyper Text Markup Language HTML is not a programming language, it is a markup.
Android View Stuff. TextViews Display text Display images???
© 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.
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.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 10: Move! Creating Animation 1 Android.
HTML5 and CSS3 Illustrated Unit F: Inserting and Working with Images.
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
Glencoe Introduction to Web Design Chapter 4 XHTML Basics 1 Review Do you remember the vocabulary terms from this chapter? Use the following slides to.
Resources. Android Resources We’ve already talked about the different types of Android Resources DirectoryResource Type anim/XML files that define tween.
Chapter 2: Simplify! The Android User Interface
Section 4.1 Section 4.2 Format HTML tags Identify HTML guidelines
Open Handset Alliance.
Marking Up with XHTML Tags describe how a web page should look
Mobile Software Development for Android - I397
Inserting and Working with Images
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
Android SDK & App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
WPF AKEEL AHMED.
CS323 Android Getting Started
Lecture 2 b: Android Layout Basics Topics
Mobile Computing With Android ACST 4550 Android Layouts
Marking Up with XHTML Tags describe how a web page should look
Android Developer Fundamentals V2 Lesson 4
Android Topics Limited Resources and why we need to consider them.
Training & Development
Introduction to HTML.
CIS 470 Mobile App Development
Building a Simple User Interface
Android Sensor Programming
Presentation transcript:

Android Layout Basics Topics Screen resolution – Important factor in App Development Density Independent Pixels: dp vs sp XML Syntax wrap_content and match_parent Lab 2 Exercise 1

Optimal Mobile Development Mobile Apps must run optimally across a range of devices. Developers must consider the following: Processing Memory usage Screen resolution

Android Screen Resolution in the Early Days Android was first released in 2008. In 2008 there was only one commercially available device, the T-Mobile G1. It was common practice to build apps specifically with the resolution of this device in mind.

Why is Resolution important? Screen resolution is a commonly used spec when buying a device. Android developers need to build apps that function well on all Android devices. There are hundreds of different Android devices, with different resolutions, to choose from. How does this differ from Apple devices?

Screen Resolution A screen is comprised of a grid (thousands or millions) of pixels, arranged in rows and columns. Each pixel represents the bits that store information about color depth. DPI (dots per inch) describes pixel density of a screen .

Potential problem (with Android images): An image may end up too small on the higher-resolution devices. An image may end up too large on the smaller-resolution devices.

Image Solution: Density-Independent Pixel, dp Consider a 2dp by 2dp View element. The same physical size is maintained on different resolution devices. Android maps dps to a different number of pixels. dps are relative to a 160dpi screen, so one dp is one pixel on a 160 dpi screen.

Scale-Independent Pixel, sp sp is a scale-independent pixel. Usage: sp is used when defining text size. dp is used when defining image size.

Layouts and XML XML is Extensible Markup Language. XML is used to describe how an Android app is going to look. XML is used to build layouts and other data resource files. An app layout will use XML to specify where View elements will be placed on an interface screen.

Example What information is stored in this XML element?

XML syntax Option 1: XML information is stored as key/value pairs. XML elements begin with an opening angle bracket, followed by the View type. Key/value pairs are a list of attributes and values A list of attributes often ends with forward slash and a closing angle bracket. This is a self-closing tag.

Attribute /value pairs syntax  Attribute names are located the left side. Values are on the right side. Attribute values should be put in quotation marks as part of the syntax for XML. There are many attributes for a given view type. Unless specified, attributes are assigned default values. The TextView XML element below uses a self-closing tag.

XML syntax Option 2: Instead of a self-closing tag an element definition may use a separate opening tag and a closing tag. This syntax is useful when using a View that is a container. The TextView XML element below uses a closing tag.

Another Example of XML syntax Option 2 This LinearLayout is a container used to store a sequential list of items. A separate opening tag and a closing tag allows the placement of items in a container View.

wrap_content and match_parent wrap_content and match_parent are values that specify a height and width. wrap-content means that the width (and height) will accommodate the width and height of content, which may change over time. match-parent forces the view to occupy the complete area of the parent view - it will match the parent dimensions. Look at the examples below.

Lab 2 Exercise 1

Lab 2 Ex 1 Structure Task 1: Locate the images. Task 2: Place images in the drawable folder.

Lab 2 Exercise 1: Layout Design Task 3: Build the layout Lab 2 Exercise 1: Layout Design Task 3: Build the layout. Task 4: Code and test the app.

Guide for building main_layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ImageView …/> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="#62f1f6"> <TextView …. /> <Button …. /> </RelativeLayout> </LinearLayout> Add necessary attributes as key value pairs.