Android Sensor Programming

Slides:



Advertisements
Similar presentations
Android UserInterfaces Nasrullah Niazi. overView All user interface elements in an Android app are built using View and ViewGroup objects. A View is an.
Advertisements

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!)
User Interface Android Applications. Activities An activity presents a visual user interface. Each activity is given a default window to draw in. The.
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:
Android: Layouts David Meredith
Creating Android user interfaces using layouts 1Android user interfaces using layouts.
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.
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.
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.
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.
1/29/ Android Programming: FrameLayout By Dr. Ramji M. Makwana Professor and Head, Computer Engineering Department A.D. Patel.
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
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.
ANDROID – DRAWING IMAGES – SIMPLE EXAMPLE IN INTERFACE AND EVENT HANDLING L. Grewe.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
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
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.
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.
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Lecture 3 Zablon Ochomo Android Layouts Lecture 3 Zablon Ochomo
Open Handset Alliance.
Adapting to Display Orientation
Android User Interface: Understanding the Components of a Screen,
Mobile Software Development for Android - I397
Android Basic XML Layouts
Mobile Application Development BSCS-7 Lecture # 8
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
Android Introduction Hello Views Part 1.
ITEC535 – Mobile Programming
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
CMPE419 Mobile Application Development
Mobile Computing With Android ACST 4550 Android Layouts
Building User Interfaces Basic Applications
BMI Android Application will take weight and height from the users to calculate Body Mass Index (BMI) with the information, whether user is underweight,
Note Q) How to format code in Enclipse? A) Ctrl + i
CIS 470 Mobile App Development
CIS 493/EEC 492 Android Sensor Programming
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CMPE419 Mobile Application Development
Korea Software HRD Center
CMPE419 Mobile Application Development
Mobile Programmming Dr. Mohsin Ali Memon.
User Interface Screen Elements
CS 240 – Advanced Programming Concepts
Android Sensor Programming
Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Android Sensor Programming CIS 694/EEC 693 Android Sensor Programming Lecture 6 Wenbing Zhao Department of Electrical Engineering and Computer Science Cleveland State University w.zhao1@csuohio.edu 11/1/2019 Android Sensor Programming

Android Sensor Programming User Interface How ViewGroups and Layouts can be used to lay out your views and organize your application screen How to adapt and manage changes in screen orientation How to create the UI programmatically How to listen for UI notifications 11/1/2019 Android Sensor Programming

Android Sensor Programming Components of a Screen The basic unit of an Android application is an activity, which displays the UI of your application using views and ViewGroups The activity may contain widgets such as buttons, labels, textboxes, etc. Typically, you define your UI using an XML file located in the res/layout folder of your project During runtime, you load the XML UI in the onCreate() method handler in your Activity class, using the setContentView() method of the Activity class During compilation, each element in the XML file is compiled into its equivalent Android GUI class @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } 11/1/2019 Android Sensor Programming

Android Sensor Programming Views and ViewGroups An activity contains views and ViewGroups A view is a widget that has an appearance on screen Examples: buttons, labels, and text boxes A view derives from the base class android.view.View A ViewGroup (which is itself a special type of view) is to group views logically—such as a group of buttons with a similar purpose Examples: RadioGroup and ScrollView A ViewGroup derives from the base class android.view.ViewGroup Another type of ViewGroup is a Layout used to group and arrange views visually on the screen Also derives from android.view.ViewGroup FrameLayout, LinearLayout, TableLayout, TableRow, GridLayout, RelativeLayout 11/1/2019 Android Sensor Programming

Android Sensor Programming FrameLayout The FrameLayout is the most basic of the Android layouts FrameLayouts are built to hold one View The FrameLayout is used to help you control the stacking of single view as the screen is resized (or screens with different resolutions) 11/1/2019 Android Sensor Programming

Android Sensor Programming LinearLayout The LinearLayout arranges views in a single column or a single row Child views can be arranged either horizontally or vertically <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:layout_height="wrap_content" android:text="@string/hello" /> </LinearLayout> fill_parent: width of the<TextView> element fills the entire width of its parent wrap_content: its height is the height of its content 11/1/2019 Android Sensor Programming

Common Attributes of Views & ViewGroups 11/1/2019 Android Sensor Programming

Android Sensor Programming Units of Measurement Size of an element on an Android UI dp—Density-independent pixel. 1 dp is equivalent to one pixel on a 160 dpi screen sp—Scale-independent pixel. This is similar to dp and is recommended for specifying font sizes pt—Point. A point is defined to be 1/72 of an inch, based on the physical screen size px—Pixel. Corresponds to actual pixels on the screen. Using this unit is not recommended 11/1/2019 Android Sensor Programming

Layout Weight & Gravity <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <Button android:layout_width="160dp" android:layout_height="0dp" android:text="Button" android:layout_gravity="left" android:layout_weight="1" /> android:layout_gravity="center" android:layout_weight="2" /> android:layout_gravity="right" android:layout_weight="3" /> </LinearLayout> Layout Weight & Gravity The layout_gravity attribute indicates the positions the views should gravitate toward, whereas the layout_weight attribute specifies the distribution of available space The three buttons occupy about 16.6 percent (1/(1+2+3) * 100), 33.3 percent (2/(1+2+3) * 100), and 50 percent (3/(1+2+3) * 100) of the available height, respectively The height of each button is set to 0dp because the layout orientation is vertical 11/1/2019 Android Sensor Programming

Android Sensor Programming LinearLayout Homework #4 & 5: Create an app that produces the left output Create another app that produces the right output (combination of vertical and horizontal layouts) 11/1/2019 Android Sensor Programming

Android Sensor Programming TableLayout The TableLayout Layout groups views into rows and columns Use the <TableRow> element to designate a row in the table Each row can contain one or more views. Each view you place within a row forms a cell The width of each column is determined by the largest width of each cell in that column 11/1/2019 Android Sensor Programming

Android Sensor Programming two columns and four rows in the TableLayout <EditText android:id="@+id/txtPassword" android:inputType="textPassword" /> </TableRow> <TableRow> <TextView /> <CheckBox android:id="@+id/chkRememberPassword" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Remember Password" <Button android:id="@+id/buttonSignIn" android:text="Log In" /> </TableLayout> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent"> <TableRow> <TextView android:text="User Name:" android:width ="120dp" /> <EditText android:id="@+id/txtUserName" android:width="200dp" /> </TableRow> android:text="Password:" 11/1/2019 Android Sensor Programming

Android Sensor Programming TableLayout Homework #6: create an app with the TableLayout as described earlier and shown on the right 11/1/2019 Android Sensor Programming

Android Sensor Programming RelativeLayout The RelativeLayout enables you to specify how child views are positioned relative to each other RelativeLayout has attributes that enable it to align with another view. These attributes are as follows: layout_alignParentTop: If true, makes the top edge of this view match the top edge of the parent layout_alignParentStart: If true, makes the start edge of this view match the start edge of the parent layout_alignStart: Makes the start edge of this view match the start edge of the given anchor view ID layout_alignEnd layout_below: Positions the top edge of this view below the given anchor view ID. Accommodates top margin of this view and bottom margin of anchor view layout_centerHorizontal: If true, centers this child horizontally within its parent 11/1/2019 Android Sensor Programming

Android Sensor Programming RelativeLayout <Button android:id="@+id/btnSave" android:layout_width="125dp" android:layout_height="wrap_content" android:text="Save" android:layout_below="@+id/txtComments" android:layout_alignEnd="@+id/txtComments" /> <RelativeLayout android:id="@+id/RLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <TextView android:id="@+id/lblComments" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Comments" android:layout_alignParentTop="true" android:layout_alignParentStart="true" /> <EditText android:id="@+id/txtComments" android:layout_height="100dp” android:textSize="18sp" android:layout_alignStart="@+id/lblComments" android:layout_below="@+id/lblComments" android:layout_centerHorizontal="true" /> <Button android:id="@+id/btnCancel" android:layout_width="124dp" android:layout_height="wrap_content" android:text="Cancel" android:layout_below="@+id/txtComments" android:layout_alignStart="@+id/txtComments" /> </RelativeLayout> 11/1/2019 Android Sensor Programming

Android Sensor Programming RelativeLayout Homework #7: create an app that produces the display on the right 11/1/2019 Android Sensor Programming