PROG 38448 Mobile Java Application Development PROG 38448 Mobile Java Application Development Developing Android Apps: Components & Layout.

Slides:



Advertisements
Similar presentations
Chapter 3 – Web Design Tables & Page Layout
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.
CE881: Mobile and Social Application Programming Simon M. Lucas Layouts.
Android User Interface
CSS Layout Crash Course An Advance CSS Tutorial. Inline vs. Block Many HTML elements have a default display setting of Block. Block elements take up the.
Cascading Style Sheets. CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. CSS is a.
Tutorial 4: Designing a Web Page with Tables
 User Interface - Raeha Sandalwala.  Introduction to UI  Layouts  UI Controls  Menus and ‘Toasts’  Notifications  Other interesting UIs ◦ ListView.
CSS, cont. October 12, Unit 4. Creating a Sidebar We know how to create a sidebar –Use the float property div#sidebar{ float: left; } Item1 Item2 Item3.
Filip Debelić What is it? Android is a mobile operating system (OS) based on the Linux kernel and currently developed by Google Android,
XP Creating Web Pages with HTML Using Tables. XP Objectives Create a text table Create a table using the,, and tags Create table headers and captions.
Chapter 31 Visual Basic Controls A Form is a windows-style screen displayed by Visual Basic programs. In a form, a programmer can create objects in a form.
HTML Tables and Forms Creating Web Pages with HTML CIS 133 Web Programming Concepts 1.
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.
ITP 104.  While you can do things like this:  Better to use styles instead:
Mobile Programming Lecture 2 Layouts, Widgets, Toasts, and Event Handling.
1 Intro XAML Attribute syntax & property syntax Panels Reusable resources Controls Data binding Steen Jensen, spring 2014.
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.
CHAPTER 10 Formatting Tables and Forms. Using Tables the Right Way  HTML and XHTML have a LOT of tags dedicated to building a table  If you have only.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
Adobe Dreamweaver CS3 Revealed CHAPTER FIVE: USING HTML TABLES TO LAY OUT A PAGE.
Frank Xu Gannon University.  Linear Layout  Relative Layout  Table Layout.
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
Designing a Web Page with Tables. A text table: contains only text, evenly spaced on the Web page in rows and columns uses only standard word processing.
© 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.
Object Oriented Software Development 9. Creating Graphical User Interfaces.
UI Resources Layout Resources String Resources Image Resources.
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
Copyright© Jeffrey Jongko, Ateneo de Manila University Basic Views and Layouts.
WaveMaker Visual AJAX Studio 4.0 Training Basics: Building Your First Application Designer Basics.
ANDROID – DRAWING IMAGES – SIMPLE EXAMPLE IN INTERFACE AND EVENT HANDLING L. Grewe.
Lecture 6 More Advanced HTML Boriana Koleva Room: C54
Android Development: Basic Widgets Richard S. Stansbury 2015.
SYST Web Technologies SYST Web Technologies XHTML Forms.
MOBILE COMPUTING D10K-7D02 MC05: Android UI Design Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. M I C R O S O F T ® Developing Presentation Text Lesson 2.
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.
20-753: Fundamentals of Web Programming 1 Lecture 6: Advanced HTML Fundamentals of Web Programming Lecture 6: Advanced HTML.
Building User Interfaces Basic Applications
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.
COMP 365 Android Development.  Developing for Android  XML for user interface formatting and other scripting  Java for programming.
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
CSS.
Java FX: Scene Builder.
CSS Box Model.
CSS Box Model.
Mobile Application Development BSCS-7 Lecture # 8
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
HNDIT2417 Mobile Application Development
CIS 470 Mobile App Development
CSS Box Model.
Mobile Computing With Android ACST 4550 Android Layouts
DREAMWEAVER MX 2004 Chapter 3 Working with Tables
Building User Interfaces Basic Applications
Chapter 2: Model View Controller, GUI Components, Events
CIS 470 Mobile App Development
CSS Box Model.
Building a Simple User Interface
CS 240 – Advanced Programming Concepts
Android Sensor Programming
Presentation transcript:

PROG Mobile Java Application Development PROG Mobile Java Application Development Developing Android Apps: Components & Layout

9/8/2015Wendi Jollymore, ACES2 Review Component definition and layout is done in xml file res/layout/main.xml setContentView(R.layout.main); Each container or widget is an element Each element has attributes Define how the widget/container appears and behaves

9/8/2015Wendi Jollymore, ACES3 Why XML Layout? Easier Java code is a bit more complicated Text based and structured Easier for a GUI builder to auto-gen code Vice versa: easier for Java code to be converted to XML Keeps UI code separate Your app code won’t get messed up by auto-gen code

9/8/2015Wendi Jollymore, ACES4 The XML File Each activity will have its own XML Root element must declare Android XML namespace xmlns:android= d.com/apk/res/androidhttp://schemas.androi d.com/apk/res/android This should appear automatically

9/8/2015Wendi Jollymore, ACES5 Element IDs Each view (container, component) is assigned an ID android:id attribute Value should be We’ll talk later To reference an object in code: findViewById(R.id.componentName)

9/8/2015Wendi Jollymore, ACES6 Widgets Actual UI components are in android.widgets package Labels: TextView class/element android:text – sets the text android:typeface – sets the type face normal, sans, serif, monospace android:textStyle – bold, italic, bold_italic android:layout_width and android:layout_height How the component should resize We’ll use this for all components

9/8/2015Wendi Jollymore, ACES7 Widgets Buttons Button class/element Subclassed from TextView Therefore, you can use the same attributes we mentioned earlier Quick note about event handling Use android:onClick attribute Give it the name of any method in your code It will execute that method when clicked!

9/8/2015Wendi Jollymore, ACES8 Widgets Text Fields EditText class/element, subclass of TextView Some extra attributes you can use: android:captialize - if the field should automatically capitalize the first letter of text entered none, sentences, words, characters android:digits - if the field should only accept certain digits give it a string of digits allowed android:singleLine - single line input or multi- line input press Enter moves to the next widget (true) or makes a new line (false))

9/8/2015Wendi Jollymore, ACES9 Widgets Check Boxes CheckBox class/element Suclassed from TextView via CompoundButton Some useful Java methods: isChecked() setChecked() toggle()

9/8/2015Wendi Jollymore, ACES10 Widgets Radio Buttons RadioButton class/element Also inherits from CompountButton / TextView Supports same Java methods As we know, radio buttons work in groups Set of radio buttons can be nested inside parent RadioGroup element

9/8/2015Wendi Jollymore, ACES11 Widgets RadioGroup Giving it an ID allows you to access entire group in code android:orientation – vertical or horizontal Useful Java methods: check() – checks a specific button by ID group.check(R.id.optButton); clearCheck() – clears radio button selection getCheckedRadioButtonId() – returns ID of currently selected button Returns -1 if none selected

9/8/2015Wendi Jollymore, ACES12 Other Properties Padding Widgets/containers have a preferred size You can add padding inside the component to increase size Between contents of component and inner border of component android:padding will set all four sides android:paddingLeft, android:paddingRight, android:paddingTop, android:paddingBottom Measure in px, dip, mm

9/8/2015Wendi Jollymore, ACES13 Other Properties android:visibility Can be visible, invisible, gone Invisible leaves space in layout, gone doesn’t android:contentDescription String value Used by accessibility tools for visually challenged Similar to alt attribute in tag in HTML

9/8/2015Wendi Jollymore, ACES14 Layout: LinearLayout Box model layout widgets/containers are lined up in a column or a row Similar to FlowLayout in Java You have 5 areas of control: Orientation Fill Model Weight Gravity Margins

9/8/2015Wendi Jollymore, ACES15 LinearLayout: Orientation Defines if layout is a row or column android:orientation horizontal or vertical

9/8/2015Wendi Jollymore, ACES16 LinearLayout: Fill Model Defines how the component fills its container How they should resize, if at all android:layout_width, android:layout_height You can use specific sizes This doesn’t work well – various screen sizes, adjusting size, etc wrap_content – widget takes its preferred size, will wrap if too big match_parent – will resize to parent

9/8/2015Wendi Jollymore, ACES17 LinearLayout: Weight Defines how widgets share available space in a container Works best when fill model is set to match_parent android:layout_weight – give it a proportional value E.g. if you give a component a weight of 1 and another component a weight of 2 Second component takes up twice as much space as first component E.g. use percentages: set all layout_widths to 0, then assign percentages that add up to 100

9/8/2015Wendi Jollymore, ACES18 LinearLayout: Gravity Defines how components are aligned in the container Default is top-left android:layout_gravity left, right, center_vertical, center_horizontal, and others See LinearLayout.LayoutParams class

9/8/2015Wendi Jollymore, ACES19 LinearLayout: Margins Defines how much space goes between components Outside component borders Remember padding is inside borders android:layout_margin sets all 4 sides android:layout_marginTop, android:layout_marginBottom, android:layout_marginRight, android:layout_marginLeft Same measurements as padding

9/8/2015Wendi Jollymore, ACES20 Example Label with text field, and two buttons

9/8/2015Wendi Jollymore, ACES21 Layout: RelativeLayout Lays out components relative to each other and their containers Requires you to reference other components E.g. layout component A to the left of component B We’ve for I.D.s You only need the + the first time you reference a component Even if the first time you reference is in another component’s attributes

9/8/2015Wendi Jollymore, ACES22 RelativeLayout Attributes that postion relative to the container: android:layout_alignParentTop aligns widget's top with top of container android:layout_alignParentBottom aligns widget's bottom with bottom of container android:layout_alignParentLeft aligns widget's left side with container left side android:layout_alignParentRight aligns widget's right side with container left side

9/8/2015Wendi Jollymore, ACES23 RelativeLayout Continued… android:layout_centerHorizontal positions widget horizontally at centre of container android:layout_centerVertical positions widget vertically at centre of container android:layout_centerInParent positions widget vertically and horizontally centred in the container each takes true or false padding is taken into account - based on widget's overall space (preferred size plus padding)

9/8/2015Wendi Jollymore, ACES24 RelativeLayout Attributes that postion relative to other widgets: android:layout_above widget should be placed above the referenced widget android:layout_below widget should be placed below the referenced widget android:layout_toLeftOf widget should be placed to the left of referenced widget android:layout_toRightOf widget should be placed to the right of referenced widget

9/8/2015Wendi Jollymore, ACES25 RelativeLayout Continued… android:layout_alignTop widget’s top should be aligned with top of referenced widget android:layout_alignBottom widget's bottom should be aligned with bottom of referenced widget android:layout_alignLeft widget's left side should be aligned with left of referenced widget android:layout_alignRight widget's right side should be aligned with right of referenced widget

9/8/2015Wendi Jollymore, ACES26 RelativeLayout Continued… android:layout_alignBaseline widget's baseline should be aligned with baseline of referenced widget useful for aligning fields and their prompts

9/8/2015Wendi Jollymore, ACES27 Example Do the same example as before, using RelativeLayout containers