Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Lập trình Android: Tạo BackGround pdf
Nội dung xem thử
Mô tả chi tiết
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