如何设置图像backgound显示? [英] How to set image in backgound display?

查看:173
本文介绍了如何设置图像backgound显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在应用程序的后台设置一个形象?
如何设置呢?

I want to set a image in background of App? How to set this?

推荐答案

把你的背景在绘制资源文件夹PNG(我们假设它的mybackground.png在我们的片段)。

Put your background PNG in the 'drawable' resources folder (we assume it's mybackground.png in our snippets).

如果您使用XML布局以下内容添加到您的顶层容器元素:

If you use the XML layouts add the following to your top level container element:

android:background="@drawable/mybackground"

例如:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

或者,如果你动态构造你的看法,然后做在活动onCreate方法如下:

Or if you construct your view dynamically, then do the following in the Activity onCreate method:

view.setBackgroundDrawable(R.drawable.mybackground)

这篇关于如何设置图像backgound显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆