【android基础】之Android设置背景图片【原创】

您所在的位置:网站首页 android如何设置背景图片 【android基础】之Android设置背景图片【原创】

【android基础】之Android设置背景图片【原创】

2022-05-15 18:00| 来源: 网络整理| 查看: 265

Android开发,设置背景图片 Android1.6运行通过 开发环境:NentBeans6.9.1 + nbandroid

1.先在建好的工程目录(我的是:D:\我的文档\NetBeansProjects\Android1.6工程\背景图片\AndroidBgImg\res\)下 新建一个drawable文件夹,把背景图片放进去,我用的是bg1.png,如下:

2.修改main.xml,在LinearLayout 里添加android:background="@drawable/bg1"这个属性即可:

   

3.java代码

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package org.me.androidbgimg;

import android.app.Activity; import android.os.Bundle;

/** * * @author Administrator */ public class AndroidBgImg extends Activity {

    /** Called when the activity is first created. */     @Override     public void onCreate( Bundle icicle )     {         super.onCreate( icicle );         // ToDo add your GUI initialization code here            this.setContentView( R.layout.main );        } }

运行效果:



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3