2015-04-24 63 views
2

我正面临着这个恼人的问题,我的应用程序背景图像显示在模拟器上,但没有显示在我的Samsung S4 Active Device上。我试图在另一台设备上执行该应用程序,它工作,但我不知道我的手机发生了什么。我做了工厂重置,但无济于事。我正在使用Android Studio进行编码,几天前一切正常,但现在当我尝试另一个图像并且在手机中正常工作时,我遇到了特定背景图像的问题。背景图像没有在手机上显示

有没有人遇到这样的问题?任何帮助将不胜感激,因为我无法继续因为这个问题。

enter code here` 
 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" 
 
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" 
 
    android:paddingRight="@dimen/activity_horizontal_margin" 
 
    android:paddingTop="@dimen/activity_vertical_margin" 
 
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity" 
 
    android:background="@drawable/background_draft"> 
 
    <TextView android:text="@string/hello_world" android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     /> 
 
    </RelativeLayout> 
 

感谢您的帮助。

问候, GB

+0

如果您发布了一些代码,这将有所帮助。问题可能出现在不同的版本中,因为'setBackgroundDrawable'已被弃用。 –

+0

感谢您的快速回复。我将发布代码,但它只是一个可绘制文件夹中的png图像,并且我使用了xml代码android:background =“@ drawable/background_draft”代码来呈现图像。我在另一部手机上尝试了相同的代码,并且工作正常。 –

+0

在这种情况下,它可能是内存不足的例外,尤其是在不同的图像正常工作的情况下。手机崩溃时会引发什么异常? –

回答

8

减少对我解决了这个问题,也图像大小。我试图使用1080 x 1920的JPG格式。当我将其缩小到540 x 960时,背景图像出现在我的设备(常规GS4)中。感谢堆栈。

+0

谢谢,一直想知道这一整天。 :) – user3718908