2013-05-29 225 views
1

我有一點問題。我的應用程序將使用很多外部資源來顯示按鈕,背景,字段等。問題是我想讓它適合每個尺寸的手機。如何爲Android設置背景圖片?

如果我有一個圖像500x500它不會自動縮放以適應700x800的電話。這種類型的問題有哪些常見的修復?

編輯:

<FrameLayout 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" > 

    <ImageView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:scaleType="fitXY" 
     android:src="@drawable/blue_bg_login" /> 

</FrameLayout> 

enter image description here

從你真的無法看到圖像,但它具有圖像周圍的邊框,在任何尺寸的手機分辨率。藍色應該是灰色頂部的寬度。

+0

請張貼代碼你試過什麼,結果是什麼? –

+0

你是如何設置背景的? –

+0

只是爲了確保你是'ImageView'來設置你的背景? –

回答

1

在您的FrameLayout中加入android:background="@drawable/ic_launcher"

+0

@DanielContreras抱歉,我沒有完全明白你的意思,你可以打印模擬器的屏幕併發布圖像,所以我們可以看到確切的問題。 –

+0

對不起,你是對的,我必須完全從ImageView中刪除圖像。謝謝。 –