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.完成,实际效果如下:

 

 

 

Logo

一站式虚拟内容创作平台,激发创意,赋能创作,进入R空间,遇见同道,让优质作品闪耀发光。​

更多推荐