You are on page 1of 5

B2: Di toi res/main.

xml
Mii:

d6 xay dung

giao dien cho chuang trinh:

<?xml version="l.O" encoding="utf-8"?> <LinearLayout ~~ ~~:ns: android=''http://schemas .an~d~r~m/aPk/res/andro android:orientation="vertica android:layout_width="fill~r nt" android: layout _ height=" fi~p:arent" :EditText android:id="@+id/ 0 enter" android:layout_ ='fill_parent" android:layo t 'ght="wrap_content" android:hint= 'ng/work_hint" android: lin android :~rr:~s,Slze=" 24px"

§~~

/>

<LinearL~~y andro' yout width="wrap content" andr i ·layout_height="wrap_content" ~~~~ :orientation~"horizontal" <TextView android:layout_width="50px" android:layout_height="wrap android:text="@string/hour android:typeface="normal" android:textSize="15px" android:textStyle="bold"

~1;
~v

content" edit"

android:padding="Spx" /> <EditText android:id="@+id/hour edit" android:layout_width="4Spx" android:layout_height="wrap content" android:hint="12" android:textColorHint="@color/hint color" android:textSize="20px" android:gravity="center" android:padding="Spx" android:numeric="integer" android:maxLength="2" /> <TextView Cj android:layout widt " android:layout_height ' rap content" android: text=" @strA~:~s!minute edi t" _ android: typefaCe~~TInal" android:textS~' z~~Spx" android:textS ="bold" android:padd~ px"

0Y~ g

©;:;J0

~~ditText androi . ~id/minute edit" android: yout_width="4Spx" and~layout_height="wrap_content" an§tR~:~hint=" 00" ~~: textColorHint=" @color /hin t_ color" id:textSize="20px" id:gravity="center" droid:padding="Spx" droid:numeric="integer" android:maxLength="2" /> </LinearLayout> <Button android:id="@+id/button" android:layout_width="wrap content" android:layout_height="wrap content"

~~~1~

android:gravity="center" android:text="@string/button content" /> <ListView android:id="@+id/list" android:layout_width="fill parent" android:layout_height="wrap content" /> </LinearLayout> ~ (!~o

(;~~~~~~)
;. hinh, cac thanh ng viec), I Linear

Giao dien ta thiet ke (] day co I Linear Layout him than phan con cua no gBm I Edit Text (dung de nhap nQi d

Layout (lai gBm cac thanh phan con de nhap gi~' '~ lit hire hien cong viec), I Button (de them nQi dung cong viec vao List V· v' List View dung de list cac cong viec ban da nhap.

...

ro kho~ lines duoc

dung d~ ~6dinh S6r~#' dung moi wrap_content vi neu sd w:~ent dong nhap vao virot gioi han

dU1~~~tJ3m
o v

nen sir dung voi Edit Text ~Y vi thi Edit Text se tv gi~n ~a neu

hong giao dien ban thiet ke),

~oa gravity thong bao ~~~~ phan con se duoc siir x~ ntn a thanh phfu, chao day minh dung '~' nghia la thanh phan con nam (] trung tam. Hay thir them vao I Edit Text; ~

ro

Ma: android:g

~ y="center"

Ban se th~y dong chfi nhap vao se b~t dAu ill gifra cua Edit Text chir khong b~t dAu ill ben trai nhir tnroc nira. Til khoa padding dung de each I khoang each cho thanh phan, Neu khong co padding thi 2 thanh phAn con thuoc cung I LinearLayout se diroc xep sat nhau, nhung neu I thanh phAn con sir dung padding thi se tao duoc khoang each voi

thanh phan con lai theo mong muon, N goai ra con co paddingLeft, paddingRight, paddingTop, paddingBottom. Til khoa numeric dung de gioi han dang ky ur nhap vao, d day minh muon chi nhap vao chir sB nen dung "integer" Til khoa maxLength dung de gioi han sB ky tv nhap vao. Do Edit Text nay dung de nhap gio nen maxLength="2" . Ok, gio d6n 1 ~hut ki,6nthirc v6 cac don vi cua dimenson: - px (pixel): diem cham tren man hinh. - in (inch) - mm (milimet) - pt (point) = -1172m - dp (density i~dependent pixel): cai nay hoi kho giai sir dung ch~ nhieu dQ phan giai, va voi dQphan ~~~ - sp: gan giong dp, nen sir dung cho text size. Noi ,chung nen sir dung dp va sp de dinh ngh~e l~ co dinh vo:i dQ phan giai cua man hinh. phan giai nhat dinh thi dung px cho chi~n~ ~a

~!~~~~
, . Noi chung dp diroc xlinch thi 1 dp = 1 px.

,;{'!!J
(p ~

~eu

cho cac thanh phan, vi no co ti ban c~u tam xay dung cho 1 dQ chac chan.

B3:
Ma:

Too values/strings.xml

chinh

Sir~~~J\~U:
C)

<?xml version="l.O" ncoding="utf-8"?> <resources> <string na~~'a~ _name">Example 2</string> <string na 'ork_hint">Enter the work here</string> <strin ="hour_edit">Hour</string> <stri e="minute_edit">Minute</string> me="button content">Add work</string> </resources>
B4: Tao moi colors.xml trong values voi nQi dung:

Ma: <?xml version="l.O" encoding="utf-8"?>

<resources> <color narne="hint color">#cccccc</color> </resources>

OK, v~y hi dff hoan thien phan giao dien, Cac ban co th€ cho chay thir ngay d€ kiem tra xem giao dien dff nhu y muon chua chir khong cAndoi hoan thanh ca code (Run as -> Android Application).

You might also like