Thi t k giao di n trên Androidế ế
MultiUni
Tr n Vũ T t Bình
T ng quan
Trong Android, dùng Activity đ hi n th màn
hình.
M i activity s ch a các View theo d ng c u
trúc cây, nghĩa là m t Layout g c ch a các
view/layout con bên trong ho c ch có 1 view
duy nh t. (l u ý Layout cũng là m t view ư
nhé)
Có th thi t k giao di n trong code java ế ế
ho c trong file xml trong th m c layout. ư
Tree view
Layout m u c a helloworld
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent”>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=“@string/hello“ />
</LinearLayout>
M t s thu c tính c b n ơ
Layout_width, layout_height: chi u r ng c a
view (fill_parent là to b ng kích th c c a ướ
layout ch a view này, wrap_content là v a đ
n i dung c n hi n th c a view)
Orientation: v i LinearLayout, vi c s p x p ế
các view là n m k nhau theo hàng ngang
ho c hàng d c, ta khai báo orientation đ
ch n s p theo ki u nào (horizontal/vertical)