Android Layouts. Layouts Define the user interface for an activity Layouts are defined in.xml files – within /res/layout folder – different layout can.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Android UserInterfaces Nasrullah Niazi. overView All user interface elements in an Android app are built using View and ViewGroup objects. A View is an.
Android User Interface
Who Am I And Why Am I Here I’m professor Stephen Fickas in CIS – you can call me Steve. I have a research group that works with mobile devices (since 1995!)
Layout and Control in UI The user interface (UI) is the graphical interface user can see and interact with your app comprising UI controls like textbox,
CS378 - Mobile Computing User Interface Basics MIKE!! LOOK HERE FOR intercepting the ListView items:
Presenting Lists of Data. Lists of Data Issues involved – unknown number of elements – allowing the user to scroll Data sources – most common ArrayList.
Android: Layouts David Meredith
Creating Android user interfaces using layouts 1Android user interfaces using layouts.
Android Development: Application Layout Richard S. Stansbury 2015.
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.
PROG Mobile Java Application Development PROG Mobile Java Application Development Developing Android Apps: Components & Layout.
Mobile Programming Lecture 2 Layouts, Widgets, Toasts, and Event Handling.
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.
Android Fundamentals and Components Kris Secor Mobile Application Development.
Linear Layout, Screen Support, and Events. Linear Layout Supports 2 orientations: 1.Horizontal 2.Vertical I often get confused with how each orientation.
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.
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
Programming with Android: Layouts, Widgets and Events Luca Bedogni Marco Di Felice Dipartimento di Scienze dell’Informazione Università di Bologna.
User Interfaces: Part 1 (View Groups and Layouts).
Application Development for mobile Devices
Presented By: Muhammad Tariq Software Engineer Android Training course.
Copyright© Jeffrey Jongko, Ateneo de Manila University Basic Views and Layouts.
UI Design and Development +Roman Nurik +Nick Butcher.
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.
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.
CS378 - Mobile Computing User Interface Basics. User Interface Elements View – Control – ViewGroup Layout Widget (Compound Control) Many pre built Views.
Building User Interfaces Basic Applications
Android View Stuff. TextViews Display text Display images???
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.
Chapter 2 Building User Interfaces and Basic Applications.
Building User Interfaces and Basic Applications Chapter 2 1.
Http :// developer. android. com / guide / topics / fundamentals. html.
CS371m - Mobile Computing User Interface Basics. UI Programming with Widgets Widget is an element in a Graphical User Interface (GUI) – not to be confused.
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
You have to remember that  To create an AVD(Android Virtual Device)  The Structure of Android Project  XML Layout  The advantage of XML Layout  Android.
Android Fundamentals. What is Android Software stack for mobile devices Software stack for mobile devices SDK provides tools and APIs to develop apps.
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Resources. Android Resources We’ve already talked about the different types of Android Resources DirectoryResource Type anim/XML files that define tween.
Open Handset Alliance.
Mobile Software Development for Android - I397
Linear Layout, Screen Support, and Events
Mobile Application Development Chapter 3 [Using Eclipse Android Studio for Android Development] IT448-Fall 2017 IT448- Fall2017.
Android Basic XML Layouts
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
CIS 470 Mobile App Development
Android Layout Basics Topics
CIS 470 Mobile App Development
Lecture 2 b: Android Layout Basics Topics
Mobile Computing With Android ACST 4550 Android Layouts
Building User Interfaces Basic Applications
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Korea Software HRD Center
Building a Simple User Interface
Mobile Programmming Dr. Mohsin Ali Memon.
User Interface Screen Elements
CS 240 – Advanced Programming Concepts
User Interface Development
Android Sensor Programming
Android Sensor Programming
User Interface Development
Presentation transcript:

Android Layouts

Layouts Define the user interface for an activity Layouts are defined in.xml files – within /res/layout folder – different layout can be designed for lanscape view placed within /res/layout-land folder Handful of layouts to choose from All derived from the class: android.view.ViewGroup

View class Any widget or ViewGroup placed as part of interface on an Activity is a View – 11 direct subclasses – 62 indirect subclasses LinearLayout TableLayout EditText Button Others

View attributes Apply to any instance of a View – syntax: android:layout_attribute_name=“value” – layout_height and layout_width values: match_parent or wrap_content fill_parent deprecated (renamed to match_parent as of 2.2) – layout_margin extra space on all sides of item – layout_marginX (i.e. X= Top, Bottom, Right, Left) – layout_gravity – gravity – text (for labels, buttons, etc.)

Sizing options preferred units – dp or dip – device independent pixels scales size according to screen density 1 dp is equivalent to 1 pixel on 160 dpi screen – sp – scale-independent pixels scales fonts according to user’s font size other options – px actual pixels – mm and in – millimeters and inches – pt – points (1/72”)

Layouts Available layouts – AbsoluteLayout Deprecated as of allowed specific x, y coordinates – Common Layouts LinearLayout – Default – Allows child items to be placed in a single row or column TableLayout – Allows child items to be placed in multiple rows and columns – More sophisticated/specialized layouts RelativeLayout – Allows child items to be placed relative to each other FrameLayout – Allows child items to be stacked on one another

LinearLayout Child items placed in single row or column – Important attributes for LinearLayout orientation – applies to parent – “vertical” = single column – “horizontal” = single row layout_width and layout_height – decide if the layout should take up: » the entire width (height) of the screen » minimum width (height) needed » specific width (height) desired

Sample.xml file <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width=“match_parent“ android:layout_height=“match_parent“ > <TextView android:layout_width=“match_parent" android:layout_height="wrap_content“ android:layout_margin="2dp“ android:text="View me" /> <Button android:layout_width=“match_parent" android:layout_height="wrap_content" android:layout_margin=“2dp" android:text="Push me" />

TableLayout Places items in rows and columns Important attributes – collapseColumns (hides columns) =“*”, =“1”, =“0,3”, etc. – stretchColumns (displays columns) – layout_span allows child to span multiple columns

Sample.xml file <TableLayout xmlns:android=“ android:layout_width=“match_parent“ android:layout_height=“match_parent" android:stretchColumns=“*" > <Button android:text="Cell 1,1“/> <Button android:text="Cell 1,2”/> <Button android:text="Cell 2,1”/> <Button android:text="Cell 2,2”/>

RelativeLayout Currently the default layout supplied in Eclipse Tends to work the best with the visual editor Where child items are in relation to: – parent – each other Sometimes allows for one layout to be used instead of layouts within layouts Many attributes – See documentation on RelativeLayout.LayoutParams class

RelativeLayout Important attributes – layout_X where X is: centerInParent centerHorizontal (or Vertical) alignParentTop (or Bottom or Left or Right) alignRight (or Left or Top or Bottom) – – aligns specified edge of each child – often causes overlap above (or below or toLeftOf or toRightOf) – – aligns children relatively to each other accordingly

Sample.xml file <RelativeLayout xmlns:android=“ android:layout_width=“match_parent“ android:layout_height="match_parent“ > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content“ android:layout_centerInParent="true“ android:text="View me“ /> <Button android:layout_width="wrap_content“ android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="Push me" />

FrameLayout Places items on top of each other <FrameLayout xmlns:android=“ android:layout_width=" match _parent“ android:layout_height=" match _parent“ > <TextView android:layout_width="wrap_content“ android:layout_height="wrap_content“ android:text="This is big text!“ android:textSize="20pt“ /> <TextView android:layout_width="wrap_content“ android:layout_height="wrap_content“ android:text="I am small...“ android:textSize="8pt" />

Layout Orientations Portrait – Default view Landscape – When device is rotated 90 ° To set specific layouts for each – \res\layout\main.xml for portrait layout layout folder is provided – \res\layout-land\main.xml for landscape layout layout-land folder must be created – file name and variable names within file must match – not restricted to main.xml

Layout Orientations Orientation can be locked – screenOrientation attribute of Activity android:screenOrientation="portrait" – Each Activity handled separately can do any combination of locked and unlocked Activities can lock all, but must do each individually

Common Views User-interface views placed within layouts – TextView – EditText – Button – CheckBox – RadioButton – Spinner – Many others

Determining a given View’s.xml attributes Use Android reference to find class – Example: Button View XML attributes of the class – Button does not have any listed View XML attributes of the Ancestor classes – In this case, TextView and View Use eclipse pop-up help in.xml file