Lập trình Android: Tạo BackGround pdf

3 334 1
Lập trình Android: Tạo BackGround pdf

Đang tải... (xem toàn văn)

Thông tin tài liệu

Trung tâm Tin học – ĐH KHTN 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.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" android:textColor="@color/Orange" android:textSize="24dip" android:layout_centerHorizontal="true" android:id="@+id/infotext"></TextView> <ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:background="@drawable/background" android:id="@+id/countryimage" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="67dp"></ImageView> </RelativeLayout> </LinearLayout> Như vậy bạn thấy đã chèn thêm 1 Control ImageView và TextView vào ứng dụng ban đầu trong đó ImageView đóng vai trò là hình nền. Lập trình Android – http://laptrinhdidong.vn Page 1 Trung tâm Tin học – ĐH KHTN 3/ 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: Lập trình Android – http://laptrinhdidong.vn Page 2 Trung tâm Tin học – ĐH KHTN Cá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 ^^ Lập trình Android – http://laptrinhdidong.vn Page 3 . <ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android :background= "@drawable /background& quot; android:id="@+id/countryimage" android:layout_alignParentTop="true". android:text="@string/info_text" android:layout_alignParentBottom="true" android:textColor="@color/Orange" android:textSize="24dip" android:layout_centerHorizontal="true" android:id="@+id/infotext"></TextView> . 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"

Ngày đăng: 07/08/2014, 08:22

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan