2016-07-25 119 views

回答

0

在style.xml定义它在你的主题

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="android:background">@drawable/</item> 
</style> 

0

把你的图像文件中可绘制文件png格式和所有的活动做在你所有的XML布局

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:orientation="vertical" 
    android:clipToPadding="false" 
    android:paddingBottom="4dp" 
    android:background="@drawable/yourImage" 
    android:layout_height="match_parent"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

</RelativeLayout> 
+0

谢谢,我已经知道这一点。我想找到一种不需要在每个活动中写下来的方法。 –

+0

这是正确的方式来做到这一点,就像其他答案表明它可能会导致问题一样,比如软键盘打开时显示它后面的图像 –

1

你可以这样做:

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="android:windowBackground">@drawable/PICTURE_NAME</item> 
</style> 
0

嗯,这取决于你有多少活动,您将需要的背景属性设置为每一项活动根元素是这样的:

<LinearLayout 
    ... 
    ... 
    android:background="@drawable/background_image" 
</LinearLayout> 

作为上面的例子,我使用了LinearLayout。您应该将它替换为活动布局文件中的任何根元素!

我希望这有助于!