Cách chèn hình tự chọn làm hình nền Sau đây mình sẽ demo cách bạn chọn 1 hình bất kỳ làm hình nền cho ứng dụng: 1/ Bạn tạo 1 project như sau: Project name: Global Build Target: Android 2
Trang 1Cách chèn hình tự chọn làm hình nền Sau đây mình sẽ demo cách bạn chọn 1 hình bất kỳ làm hình nền cho ứng dụng: 1/ Bạn tạo 1 project như sau:
Project name: Global
Build Target: Android 2.3.3
Application name: Global
Package name: org.example.GlobalExample
Create Activity: GlobalExample
2/ Trong phần main.xml bạn chỉnh lại như sau:
<?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"
/>
<RelativeLayout android:layout_width ="fill_parent"
android:layout_height ="fill_parent"
xmlns:android ="http://schemas.android.com/apk/res/android"
android:id ="@+id/iclLayout">
<TextView android:layout_width ="wrap_content"
android:layout_height ="wrap_content"
android:text ="@string/info_text"
android:layout_alignParentBottom ="true"
Trang 23/ Bạn tạo thêm 1 folder “drawable” trong phần “res” và Import 1 image vào trong drawable Tiếp theo bạn rename Image lại thành “background” (lưu ý bỏ đuôi png) 4/ Sau đó bạn chỉnh file strings.xml như sau:
<?xml version ="1.0" encoding ="utf-8"?>
<resources>
<string name ="hello">Hello, Hi`nh ne`</string>
<string name ="app_name">Global</string>
<string name ="info_text">Trái đất</string>
</resources>
5/ Để thêm phần màu mè bạn thêm 1 file color.xml vào thư mục values(trong thư mục res) Và code vào như sau:
<?xml version ="1.0" encoding ="UTF-8"?>
<resources>
<color name ="Orange">#ff3300</color>
</resources>
Cuối cùng bạn cho Debug ứng dụng và sẽ được kết quả như sau:
Trang 3Các bạn có thể đóng góp ý kiến, trao đổi bằng cách post bài vào forum trang web
www.laptrinhdidong.vn Mình sẽ cập nhật forum thường xuyên ^^