【发布时间】:2011-10-16 14:44:03
【问题描述】:
我想在应用程序的背景中设置图像? 这个怎么设置?
【问题讨论】:
我想在应用程序的背景中设置图像? 这个怎么设置?
【问题讨论】:
将背景 PNG 放入“可绘制”资源文件夹中(我们假设它是我们 sn-ps 中的 mybackground.png)。
如果您使用 XML 布局,请将以下内容添加到您的顶级容器元素中:
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">
或者如果你动态构建你的视图,那么在Activity的onCreate方法中做如下操作:
view.setBackgroundDrawable(R.drawable.mybackground)
【讨论】: