将背景图像设置为已具有主题的应用程序

时间:2012-10-04 08:48:08

标签: android background-image android-theme

您好我想将背景图片设置为已有主题的应用程序。

<application   android:theme="@android:style/Theme.NoTitleBar" />

现在我已将代码更改为此

  <style name="BackgroundImage" parent="@android:style/Theme.NoTitleBar">
    <item name="android:background">@drawable/background</item>
</style>

清单文件看起来像这样

 <application   android:theme="@style/BackgroundImage" />

现在设置了背景图片,但我之前的主题即Theme.NoTitleBar无效。

预期的理想行为是背景图像和Theme.NoTitleBar应该工作。我该怎么办?

2 个答案:

答案 0 :(得分:1)

我通过这样做改变了样式,我重写了Theme.NoTitlteBar

 <style name="Background" parent="@android:style/Theme.NoTitleBar">
    <item name="android:windowBackground">@android:color/black</item>
    <item name="android:windowNoTitle">true</item>
</style>

现在清单文件看起来像这样。

<application  android:theme="@style/Background"/>

答案 1 :(得分:0)

您需要在xml文件中执行此操作,而不是清单。

你必须这样做:

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

android:background="@drawable/yourimage" >   //your drawable image here
希望我帮助你