android背景图片,android背景图片自动滚动

在android编程中怎么插入背景图片啊?

我知道的有两种方法。首先你先将一个.png的背景图片存入工程中res/drawble(当然drawble-hdpi、drawble-mdpi、drawble-ldpi中一个或者几个文件夹都可)文件夹中。假如我存入的图片名称为activity_bg.png

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名注册、网页空间、营销软件、网站建设、临漳网站维护、网站推广。

第一种,在对应的布局文件(自动生成的工程默认文件是在res/layout中的main.xml)中的LinearLayout(默认)属性中添加android:background="@drawable/activity_bg"

第二种,在你要添加背景的activity的类文件中setContentView(R.layout.main);(默认)之后添加一句getWindow().setBackgroundDrawableResource(R.drawable.activity_bg);

两种方法都能实现在activity中添加背景,第二种方法一定要先setContentView()再设背景,不然报错

Android app中如何设置背景图片

是因为你把这个图片放在了drawable-land文件夹下,你放到drawable-hdpi下试试看。

android设置背景图片

教你如何设置背景图片

xml文件设置背景图片中:

任意一个控件,button imageView 或layout,在其的xml属性设置中,添加

[java] view plaincopy

android:background="@drawable/bg"

即可实现设置其背景图片为bg.

其中bg.bnp图片存放在drawable目录下。

drawable目录下存放大小图标共用的图片。drawable-hdpi中存放240 WVGA800 的模拟器或板子用的图片。drawable-mdpi存放对应的小图片

[java] view plaincopy

ImageView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:src="@drawable/pic"/

同样,用src属性,也可设置imageView的图片为pic.png

java代码中设置或更改一个控件的背景图片:

[java] view plaincopy

Resources resources = getContext().getResources();

Drawable btnDrawable = resources.getDrawable(R.drawable.layout_bg);

layout.setBackgroundDrawable(btnDrawable);

程序中,动态修改layout的背景图片,用setBackgroundDrawable()函数实现。设置其背景图片为 layout_bg.png

修改imageView1的背景图片为imageView2的背景图片:

imageView2.getDrawable()可获得图片2的背景。值为Drawable类型

imageView1.setImageDrawable(drawable); 设置imageView1的背景图片

即:

[java] view plaincopy

imageView1.setImageDrawable(imageView2.getDrawable());

怎样在android中添加背景图片

怎样在android中添加背景图片?

1.打开左侧的工程文件夹。打开res中的layout,双击main.xml。

2.一般的图片是jpg格式的,要把格式转化为png格式的。

3.把PNG格式的图片拖到工程中res中的drawable-hdpi中

4.在main.xml中的LinearLayout下面,添加Android:background="@drawable/**"。**是添加进来的图片名字。

Android Tips:

在给drawable中添加图片资源时,文件名必须全小写


网页标题:android背景图片,android背景图片自动滚动
当前网址:http://ybzwz.com/article/dsgiope.html