您的位置:首页 > 移动开发

Android Studio App设置Activity背景图片

2015-08-21 08:42 686 查看
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.完成,实际效果如下:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: