manifest view & basic layout lab...

28
Mobile Programming Practice Manifest View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong

Upload: others

Post on 12-Mar-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Mobile Programming Practice

▪ Manifest

▪ View & Basic Layout

▪ Lab #1

1

Prof. Hwansoo Han

T.A. Sung-in Hong

Page 2: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Lecture Schedule

Spring 2019 (Tuesday)

This schedule can be changed

M

A

R

C

H

5 12 19 26

IntroductionAndroid overview

& basic layoutLayout Advanced UI

A

P

R

I

L

2 9 16 23 30

Broadcast receivers

PA#1Services Project proposal

MID TERM

(no exam)

Content providers

M

A

Y

7 14 21 28

Advanced concepts

(1)

APIs (1)

PA#2APIs (2) Profile

J

U

N

E

4 11 18

Intro. to the Kotlin

Project

Final

Presentation

END TERM

(no class)

2

Page 3: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Android app. components

▪ Activities

▪ Services

▪ Broadcast receivers

▪ Content providers

Each type serves a distinct purpose and has a

distinct lifecycle that defines how the component

is created and destroyed.

3

Page 4: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Android project overview

MyProject/

app/

manifest/

AndroidManifest.xml

java/

res/

4

Page 5: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

The manifest file

▪ Before the Android system can start an app

component, the system must know that the

component exists by reading the app's manifest

file, AndroidManifest.xml. Your app must declare

all its components in this file, which must be at

the root of the app project directory.

5

Page 6: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

AndroidManifest.xml

6

① Package name

② App components

③ Intent filters

Page 7: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Android project overview

MyProject/

app/

manifest/

java/

res/

layout/

activity_main.xml

content_main.xml

7

Page 8: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

View

8

▪ A View is an object that

draws something on the

screen that the user can

interact

▪ A Viewgroup is an object

that holds other View

objects in order to define

the layout of the user

interface.

TextView!

Page 9: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

View classes

9

https://www.formget

.com/android-views/

Page 10: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Layouts

▪ A layout defines the structure for a user

interface in your app, such as in an

activity.

10

Figure 1. Illustration of a view hierarchy, which defines a UI layout

Page 11: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Two ways to declare a layout

▪ Declare UI elements in XML.

• Android provides a straightforward XML vocabulary that

corresponds to the View classes and subclasses, such

as those for widgets and Layouts. You can also use

Android Studio's Layout Editor to build your XML layout

using a drag-and-drop interface.

▪ Instantiate layout elements at runtime.

• Your app can create View and ViewGroup objects (and

manipulate their properties) programmatically.

11

Page 12: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

XML (Extensible Markup Language)

▪ Using Androids’ XML vocabulary, you can quickly design UI layouts and the screen elements they contain

12

<?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" >

<TextView android:id="@+id/text"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Hello, I am a TextView" />

<Button android:id="@+id/button"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Hello, I am a Button" />

</LinearLayout>

Page 13: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Attributes of Layout

▪ ID

• Any View object may have an integer ID

• android:id=“@+id/my_button”

• @ symbol at the beginning of the string indicates that the

XML parser should parse and expand the rest of ID string

and identify it as an ID resource

• + symbol means that this is a new resource name that

must be created and added to our resource(in R.java file)

• Each View object can be access with ID

• Button myButton =

(Button) findViewByID(R.id.my_button);

13

Page 14: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Attributes of Layout

▪ Layout Parameters

• Help defining other attributes with relative values

• warp_content tells your view to size itself to the

dimensions required by its content

• match_parent tells your view to become as big as its

parent view group will allow

▪ Size, padding and margin

• android:layout_height=“30dp”

• android:layout_width=“wrap_content”

• android:layout_height=“wrap_content”

14

Page 15: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

dp : density-independent pixels

▪ Density-independent pixel(dp, dip) is an

Android mechanism which provides

compatibility with any possible display

density.

▪ In real world 1dp is approximately 0.2mm

▪ The interactive view should be at least 48

dp (almost 9mm)

15

Page 16: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Common Android views

▪ https://drive.google.com/file/d/0B5XIkMka

yHgRMVljUVIyZzNmQUU/view

16

Page 17: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Reference

▪ https://developer.android.com/reference/a

ndroid/widget/TextView.htm

▪ Or google “textview android”

17

Page 18: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

[Lab – Practice #1]

▪ edu.skku.cs.BasicLayout

• Add more than 5 views

• ex) TextView, Button, EditText, RadioButton, Switch, ...

• Change/add attributes of each view

• ex) textSize, textColor, ...

▪ Upload your Layout file to i-Campus

• Lab#1

18

Page 19: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

APPENDIX A –

Usefule references

19

Page 20: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Useful references

▪ For UI & design

• https://material.io/

▪ Android common views

• https://drive.google.com/file/d/0B5XIkMkayHgRMVlj

UVIyZzNmQUU/view

▪ XML Layout emulator

• https://labs.udacity.com/android-

visualizer/#/android/other-text-view-attributes

20

Page 21: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

APPENDIX B –

Course overview

21

Page 22: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Course Overview

▪ Lecture + Lab

• Lecture: ~1 hour basic Android features

• Lab: ~2.5 hours programming practices

▪ Programming projects

• Almost 10 lab practices

• 2 assignments

• 1 term project (2-3 in a team)

• No exams

22

Page 23: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Course Overview

▪ Prerequisites

• Introduction to computer science

• ***Experience of Java programming***

• Data structure

▪ Grading factors

• Attendance 10%

• Lab practice 10%

• Assignment 40%

• Term Project (proposal 10% + final 30%)

23

Page 24: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Grading Policy

▪ Must – otherwise you will get ‘F’ grade

• Submit two programming assignments

• Submit term project assignment

▪ You will also get ‘F’ if you…

• Absent more than 3 times

• Attending after lecture will be counted by late (2 lates = 1 absence)

• Turn in a completely duplicated assignment

• Allow another student to turn in your work as his/her own

24

Page 25: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Contact

▪ Office (컴파일러및시스템연구실)

• 85565, Corporate Collaboration Center

▪ TA

• Sung-in Hong

[email protected]

▪ Feel free to contact me by e-mail

25

Page 26: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Glossary for beginners

▪ https://developers.google.com/android/for

-all/vocab-words/?hl=en

▪ This glossary of Android and Java vocab

words supplements the Udacity Android for

Beginners course. This course is targeted at

those who are new to programming but want

to start building Android apps.

26

Page 27: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Android Studio

▪ Android Studio is the official Integrated

Development Environment (IDE) for Android

app development, based on IntelliJ IDEA

▪ https://developer.android.com/studio

27

Page 28: Manifest View & Basic Layout Lab #1arcs.skku.edu/pmwiki/uploads/Courses/SWPractice3/02_Basic_Layout.pdf · View & Basic Layout Lab #1 1 Prof. Hwansoo Han T.A. Sung-in Hong. Lecture

Installation

28

Download link : https://developer.android.com/studio

For windows 64bit

For other options