如何在我的应用中添加背景主题和/或背景壁纸?

时间:2010-11-18 04:55:06

标签: java android

如何在我的应用中添加背景主题和/或背景壁纸?现在我的应用背景是飞机。

2 个答案:

答案 0 :(得分:4)

在包含样式的values目录中创建XML文件。它可能是这样的:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="YourTheme" parent="@android:style/Theme">
        <item name="android:windowBackground">@drawable/your_background</item>
    </style>
</resources>

要使上述情况起作用,您需要在drawable文件夹中有一个名为your_background.png的图像。然后,您可以通过在清单文件中执行此操作将该样式应用于整个应用程序或一个特定活动:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="bla.bla">
    <application android:theme="@style/YourTheme"> <!-- This is for the whole app  -->

        <activity android:name="bla.bla.YourActivity"
                  android:theme="@style/SplashTheme"/><!-- This is for a specific activity  -->

    </application>
</manifest>

答案 1 :(得分:0)

您可能正在为UI使用一些布局XML。使用要设置背景的任何图像设置布局(线性,相对等)背景。确保图像在res/drawable文件夹中可用。