manifest view & basic layout lab...

Post on 12-Mar-2020

5 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Mobile Programming Practice

▪ Manifest

▪ View & Basic Layout

▪ Lab #1

1

Prof. Hwansoo Han

T.A. Sung-in Hong

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

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

Android project overview

MyProject/

app/

manifest/

AndroidManifest.xml

java/

res/

4

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

AndroidManifest.xml

6

① Package name

② App components

③ Intent filters

Android project overview

MyProject/

app/

manifest/

java/

res/

layout/

activity_main.xml

content_main.xml

7

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!

View classes

9

https://www.formget

.com/android-views/

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

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

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>

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

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

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

Common Android views

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

yHgRMVljUVIyZzNmQUU/view

16

Reference

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

ndroid/widget/TextView.htm

▪ Or google “textview android”

17

[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

APPENDIX A –

Usefule references

19

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

APPENDIX B –

Course overview

21

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

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

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

Contact

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

• 85565, Corporate Collaboration Center

▪ TA

• Sung-in Hong

• sungin@arcs.skku.edu

▪ Feel free to contact me by e-mail

25

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

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

Installation

28

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

For windows 64bit

For other options

top related