1. 程式人生 > >Android Studio App設定Activity背景圖片

Android Studio App設定Activity背景圖片

愛看美女網(我搞的網站,幫忙點開一下吧)

1.首先PC上要有一張png格式的圖片,複製它,注意圖片名字(只能含小寫字母a~z和數字0~9,".png“要小寫),貼上進drawable資料夾。



2.在activity_main.xml裡新增下面一句,注意新增位置,/drawable/+圖片名稱。

android:background="@drawable/backimg"
整個activity_main.xml內容如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="0dp"
    android:paddingRight="0dp"
    android:paddingTop="0dp"
    android:paddingBottom="0dp" tools:context=".MainActivity"
    android:background="@drawable/backimg"
    >
    <TextView
        android:text="hello,world!"
        android:textSize="50dp"
        android:textColor="#FFFFFF"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
</RelativeLayout>

3.完成,實際效果如下: