2014-01-25 72 views
1

我学习的Android编程时遇到时,我想一个背景图像添加到该说hello android(默认的应用程序时,我们创建了一个项目)的活动的问题。我尝试了小尺寸的图像,但它很有效,但我想使用一个大图像,当我使用这个大图像时,它不适用于我的设备,即Samsung Galaxy Grand Duos。的android:背景不工作

我使用android:background="@drawable/my_big_image"activity_main.xml

<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:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity" 
    android:background="@drawable/a_real_big_image" 
    > 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/hello_world" 
    /> 
</RelativeLayout> 

内的图像是png,并且其尺寸为1688x1464。 我把这个图像放在每一个可绘制的文件夹中。

你知道如何解决这个错误吗?

在此先感谢。

+1

每张图片大概是9.8MB!你没有说什么“不起作用”意味着什么,但我猜测内存不足。 – Simon

+0

可能的重复[加载图像到Bitmap对象时出现内存不足问题](http://stackoverflow.com/questions/477572/strange-out-of-memory-issue-while-loading-an-image-位图对象) – Simon

+0

@Simon正确 - 位图占用大量内存:1688X1494 * 4 = 9.9 MB。我建议user3220206研究这个链接:http://developer.android.com/training/displaying-bitmaps/index.html –

回答

0

尝试使用涂料或其它软件某处大约400像素的宽度和尝试,如果图像然后显示了调整图像大小。

也尝试再次清洁和建立您的项目。