快速設置activity的背景圖片

 1.把圖片拷貝到res/drawable文件夾.

        (@drawable有3個文件夾drawable-hdpi,drawable-ldpi,drawable-mdpi,個人建議3個文件夾都放,因爲這涉及到尺寸,分辨率,編譯的時候它會自適應;@圖片格式是.png)

      2.然後修改layout中的main.xml,添加android:background="@drawable/pphf1">,(其中ppf1是我圖片的名稱,自己可以更改)

 

具體如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/pphf1">
>
<TextView 
     android:layout_width="fill_parent"   
     android:layout_height="wrap_content"   
     android:text="@string/welcome" 
     android:textColor="8B008B"
    />
</LinearLayout>

運行後的圖片如下:

android開發,快速設置activity的背景圖片方法


來自http://blog.sina.com.cn/s/blog_74bcfc9101013syu.html

發佈了21 篇原創文章 · 獲贊 10 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章