简体   繁体   中英

How do I set a background image for Android?

I'm having a bit of a problem. My application is going to use a lot of outside resources for buttons, backgrounds, fields, etc,. The problem is I want it to fit every size phone.

If I have an image 500x500 it won't automatically scale to fit a phone that's say 700x800. What are some common fixes for this type of problem?

EDIT:

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

在此处输入图片说明

From the image you really can't see, but it has a border around the image, in any size phone resolution. The blue should be the width of the grey up top.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM