Android View Stuff. TextViews Display text Display images???

Slides:



Advertisements
Similar presentations
Internet Basics & Way Beyond!
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
Part 5 Introduction to CSS. CSS Display - Block and Inline Elements A block element is an element that takes up the full width available, and has a line.
Custom Views, Drawing, Styles, Themes, ViewProperties, Animations, oh my!
Working with Layouts and Graphics. 1. The layout of a slide can be changed at any time during the creation of the presentation. 2. Various types of slide.
Introduction to Android Programming Content Basic environmental structure Building a simple app Debugging.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Modify Android Objects Using.
Copyright © Texas Education Agency, All rights reserved. 1 Web Technologies Website Development with Dreamweaver.
HTML, Third Edition--Illustrated Introductory 1 HTML, Third Edition Illustrated Introductory Unit F Working with Tables.
2D Graphics: Part 2.
Web Technologies Website Development Trade & Industrial Education
Chapter 10: Move! Creating Animation
6-2 2D Graphics CSNB544 Mobile Application Development Thanks to Utexas Austin.
Drawables and Skinning Widgets MOBILE SOFTWARE DEVELOPMENT.
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
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.
Website Development with Dreamweaver
 Every aspect of a Web Page should reflect the goals that led you to create the page in the first place. Not only should the text and graphics themselves.
Resources and RelativeLayouts. Resources Android Resources We’ve already talked about the different types of Android Resources DirectoryResource Type.
Frank Xu Gannon University.  Linear Layout  Relative Layout  Table Layout.
1/29/ Android Programming: FrameLayout By Dr. Ramji M. Makwana Professor and Head, Computer Engineering Department A.D. Patel.
Pasewark & Pasewark 1 Access Lesson 5 Creating and Modifying Reports Microsoft Office 2007: Introductory.
Resources. Application Resources Resources are strings, images, and other pieces of application information that are stored and maintained (externalized)
User Interfaces: Part 1 (View Groups and Layouts).
Application Development for mobile Devices
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 3 Welcome Application Introduction to Visual Programming.
UI Design and Development +Roman Nurik +Nick Butcher.
Chapter 4 Working with Frames. Align and distribute objects on a page Stack and layer objects Work with graphics frames Work with text frames Chapter.
FramesLayout & Image View Pages FrameLayout is a ViewGroup that divides the screen into blocks of area each of which is supposed to holds a single.
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???
The Web Wizard’s Guide to HTML Chapter Three Colors, Patterns, and Inline Graphics.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
Lesson 6 Formatting Cells and Ranges. Objectives:  Insert and delete cells  Manually format cell contents  Copy cell formatting with the Format Painter.
Pinnacle Pro Painting Program User Manual Created by: David Kwasny Chris Schulz W. Scott DePouw.
© 2011 Delmar, Cengage Learning Chapter 4 Working with Frames.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. M I C R O S O F T ® Developing Presentation Text Lesson 2.
Pearson Webcast Series
© 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.
CS378 - Mobile Computing User Interface Basics. User Interface Elements View – Control – ViewGroup Layout Widget (Compound Control) Many pre built Views.
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.
Logan Regional Family History Center Microfilm/Fiche Viewer/Scanner Prepared by Robert Curry 11/22/2010.
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
Cosc 5/4730 Support design library. Support Design library Adds (API 9+) back support to a number of 5.0 lollipop widgets and material design pieces –
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.
Android Application 2D Graphics cs.
Lecture 3: Animation & Graphics
Lecture 3 Zablon Ochomo Android Layouts Lecture 3 Zablon Ochomo
Mobile Software Development for Android - I397
Inserting and Working with Images
2D Graphics: Part 2.
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
HNDIT2417 Mobile Application Development
Android SDK & App Development
CS323 Android Model-View-Controller Architecture
Android Layout Basics Topics
CA16R405 - Mobile Application Development (Theory)
Android Developer Fundamentals V2
Android: Shapes.
Android Developer Fundamentals V2 Lesson 4
CIS 470 Mobile App Development
Android SDK & App Development
Korea Software HRD Center
Android Sensor Programming
UI Elements 2.
Presentation transcript:

Android View Stuff

TextViews Display text Display images???

TextView Drawables TextViews allow drawables to appear to the left of, above, to the right of, and below the text.

<LinearLayout xmlns:android=" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Drawable Left" android:layout_margin="10dp"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Drawable Top" android:layout_margin="10dp"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Drawable Right" android:layout_margin="10dp"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Drawable Bottom" android:layout_margin="10dp"/>

setError() Method available to TextView and EditText to display an error message to the user. This is very useful for user input validation.

ImageView Use this View when you want to display an image in your application. Many beginners will misuse the ImageView by using the incorrect property.

ImageView src property Use the android:src property to set a drawable as the content of the ImageView. Don’t use android:background unless you want the image to have a background img.

ImageView Example <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content"

ImageView Example with a background <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#FFFF0000"/>

ImageView scaleType Control how your image is scaled and positioned inside the ImageView – Useful when your image is too big – Useful when your image is too small

ImageView scaleType : center Scale TypeDescription centerDisplays the image centered in the view with no scaling. centerCropScales the image such that both the x and y dimensions are greater than or equal to the view, while maintaining the image aspect ratio; crops any part of the image that exceeds the size of the view; centers the image in the view. centerInsideScales the image to fit inside the view, while maintaining the image aspect ratio. If the image is already smaller than the view, then this is the same as center. fitCenterScales the image to fit inside the view, while maintaining the image aspect ratio. At least one axis will exactly match the view, and the result is centered inside the view. fitStartSame as fitCenter but aligned to the top left of the view. fitEndSame as fitCenter but aligned to the bottom right of the view. fitXYScales the x and y dimensions to exactly match the view size; does not maintain the image aspect ratio. matrixScales the image using a supplied Matrix class. The matrix can be supplied using the setImageMatrix method. A Matrix class can be used to apply transformations such as rotations to an image.

ImageView scaleType : centerCrop Scale TypeDescription centerDisplays the image centered in the view with no scaling. centerCropScales the image such that both the x and y dimensions are greater than or equal to the view, while maintaining the image aspect ratio; crops any part of the image that exceeds the size of the view; centers the image in the view. centerInsideScales the image to fit inside the view, while maintaining the image aspect ratio. If the image is already smaller than the view, then this is the same as center. fitCenterScales the image to fit inside the view, while maintaining the image aspect ratio. At least one axis will exactly match the view, and the result is centered inside the view. fitStartSame as fitCenter but aligned to the top left of the view. fitEndSame as fitCenter but aligned to the bottom right of the view. fitXYScales the x and y dimensions to exactly match the view size; does not maintain the image aspect ratio. matrixScales the image using a supplied Matrix class. The matrix can be supplied using the setImageMatrix method. A Matrix class can be used to apply transformations such as rotations to an image.

ImageView scaleType : centerInside Scale TypeDescription centerDisplays the image centered in the view with no scaling. centerCropScales the image such that both the x and y dimensions are greater than or equal to the view, while maintaining the image aspect ratio; crops any part of the image that exceeds the size of the view; centers the image in the view. centerInsideScales the image to fit inside the view, while maintaining the image aspect ratio. If the image is already smaller than the view, then this is the same as center. fitCenterScales the image to fit inside the view, while maintaining the image aspect ratio. At least one axis will exactly match the view, and the result is centered inside the view. fitStartSame as fitCenter but aligned to the top left of the view. fitEndSame as fitCenter but aligned to the bottom right of the view. fitXYScales the x and y dimensions to exactly match the view size; does not maintain the image aspect ratio. matrixScales the image using a supplied Matrix class. The matrix can be supplied using the setImageMatrix method. A Matrix class can be used to apply transformations such as rotations to an image.

ImageView scaleType : fitCenter Scale TypeDescription centerDisplays the image centered in the view with no scaling. centerCropScales the image such that both the x and y dimensions are greater than or equal to the view, while maintaining the image aspect ratio; crops any part of the image that exceeds the size of the view; centers the image in the view. centerInsideScales the image to fit inside the view, while maintaining the image aspect ratio. If the image is already smaller than the view, then this is the same as center. fitCenterScales the image to fit inside the view, while maintaining the image aspect ratio. At least one axis will exactly match the view, and the result is centered inside the view. fitStartSame as fitCenter but aligned to the top left of the view. fitEndSame as fitCenter but aligned to the bottom right of the view. fitXYScales the x and y dimensions to exactly match the view size; does not maintain the image aspect ratio. matrixScales the image using a supplied Matrix class. The matrix can be supplied using the setImageMatrix method. A Matrix class can be used to apply transformations such as rotations to an image.

ImageView scaleType : fitStart Scale TypeDescription centerDisplays the image centered in the view with no scaling. centerCropScales the image such that both the x and y dimensions are greater than or equal to the view, while maintaining the image aspect ratio; crops any part of the image that exceeds the size of the view; centers the image in the view. centerInsideScales the image to fit inside the view, while maintaining the image aspect ratio. If the image is already smaller than the view, then this is the same as center. fitCenterScales the image to fit inside the view, while maintaining the image aspect ratio. At least one axis will exactly match the view, and the result is centered inside the view. fitStartSame as fitCenter but aligned to the top left of the view. fitEndSame as fitCenter but aligned to the bottom right of the view. fitXYScales the x and y dimensions to exactly match the view size; does not maintain the image aspect ratio. matrixScales the image using a supplied Matrix class. The matrix can be supplied using the setImageMatrix method. A Matrix class can be used to apply transformations such as rotations to an image.

ImageView scaleType : fitEnd Scale TypeDescription centerDisplays the image centered in the view with no scaling. centerCropScales the image such that both the x and y dimensions are greater than or equal to the view, while maintaining the image aspect ratio; crops any part of the image that exceeds the size of the view; centers the image in the view. centerInsideScales the image to fit inside the view, while maintaining the image aspect ratio. If the image is already smaller than the view, then this is the same as center. fitCenterScales the image to fit inside the view, while maintaining the image aspect ratio. At least one axis will exactly match the view, and the result is centered inside the view. fitStartSame as fitCenter but aligned to the top left of the view. fitEndSame as fitCenter but aligned to the bottom right of the view. fitXYScales the x and y dimensions to exactly match the view size; does not maintain the image aspect ratio. matrixScales the image using a supplied Matrix class. The matrix can be supplied using the setImageMatrix method. A Matrix class can be used to apply transformations such as rotations to an image.

ImageView scaleType : fitXY Scale TypeDescription centerDisplays the image centered in the view with no scaling. centerCropScales the image such that both the x and y dimensions are greater than or equal to the view, while maintaining the image aspect ratio; crops any part of the image that exceeds the size of the view; centers the image in the view. centerInsideScales the image to fit inside the view, while maintaining the image aspect ratio. If the image is already smaller than the view, then this is the same as center. fitCenterScales the image to fit inside the view, while maintaining the image aspect ratio. At least one axis will exactly match the view, and the result is centered inside the view. fitStartSame as fitCenter but aligned to the top left of the view. fitEndSame as fitCenter but aligned to the bottom right of the view. fitXYScales the x and y dimensions to exactly match the view size; does not maintain the image aspect ratio. matrixScales the image using a supplied Matrix class. The matrix can be supplied using the setImageMatrix method. A Matrix class can be used to apply transformations such as rotations to an image.

ImageView scaleType : matrix Scale TypeDescription centerDisplays the image centered in the view with no scaling. centerCropScales the image such that both the x and y dimensions are greater than or equal to the view, while maintaining the image aspect ratio; crops any part of the image that exceeds the size of the view; centers the image in the view. centerInsideScales the image to fit inside the view, while maintaining the image aspect ratio. If the image is already smaller than the view, then this is the same as center. fitCenterScales the image to fit inside the view, while maintaining the image aspect ratio. At least one axis will exactly match the view, and the result is centered inside the view. fitStartSame as fitCenter but aligned to the top left of the view. fitEndSame as fitCenter but aligned to the bottom right of the view. fitXYScales the x and y dimensions to exactly match the view size; does not maintain the image aspect ratio. matrixScales the image using a supplied Matrix class. The matrix can be supplied using the setImageMatrix method. A Matrix class can be used to apply transformations such as rotations to an image.

ImageView ScaleType Info ?p= &seqNum=2 ?p= &seqNum=2

Android:tint ImageView’s have an attribute that allows the source image of the view to be tinted by a color.

ImageButton We’re familiar with a Button – Default background provided by the platform – Displays Text Well Android supports an ImageButton – Looks like a regular button – Default background provided by the platform – Displays an Image

Why Buttons are awesome Android provides a method for giving a button a state list that defines which images should be shown while the button is: – Normal – Focused – Enabled – Disabled – Pressed

Hiding the default background on an ImageButton If you want to use an ImageButton but don’t want to see the default background, you can hide it. – Set the android:background=“# ” – Set the

ShapeDrawables An XML file that defines a geometric shape, including colors and gradients. Creates a ShapeDrawable.ShapeDrawable

shapecornersgradientpaddingsizesolidstroke

ShapeDrawable Examples

What is a 9-Patch An Image that has the capability to specify stretchable regions.

Use Case for 9-Patch

More Info on 9-Patch Android 9 Patch Tool A Simple guide to 9-patch for Android UI