更换安卓应用的背景 java android

来源:互联网 发布:淘宝pc端首页装修教程 编辑:程序博客网 时间:2024/05/16 04:59

想要更新应用的背景:

具体步骤:

1.在xml布局文件中,对最外层的LinearLayout设置id:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/background"    android:layout_width="match_parent"    android:layout_height="fill_parent"    android:background="@drawable/background1"    android:orientation="vertical" >

2.在activity中添加:

LinearLayout background;background = (LinearLayout) findViewById(R.id.background);

3.在相应位置(你想更换背景的时候),写上代码:

background.setBackgroundResource(R.drawable.your_pic);


原创粉丝点击