开发者

How to add a background theme and/or background wallpaper to my app?

How to add a background theme and/or background wallpaper to my a开发者_如何学Gopp? Right now my app background is plane.


Create an XML file in the values directory that contains the style. It could be something like:

<?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>

For the case above to work, you need to have an image called your_background.png in the drawable folder. Then, you can apply that style to either your whole app or one specific activity by doing this in your manifest file:

<?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>


You might be using some layout XML for UI. Set layout (linear, relative, etc) background with any image you want to set your background to. Make sure that the image is available in the res/drawable folder.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜