2014-01-25 71 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像素的寬度和嘗試,如果圖像然後顯示了調整圖像大小。

也嘗試再次清潔和建立您的項目。