ParagonTime
ParagonTime

Reputation: 145

How do I get a background image to scale in android studio?

So I am trying to import a custom image as the background of an android app however it does not fill in all of the edges. The option I have seen is to set a second layout to be a frame layout and then place an image view within it with additional coding along the lines of android:scaleType="centerCrop". This will not fill the entire screen up for me however, heres a screenshot of what ends up happening -

enter image description here

Heres the xml code being used:

 <FrameLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"

    >

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/backgroundImage"
        android:background="@drawable/backgroundImgr"
        android:scaleType="centerCrop"

        />
</FrameLayout>

Another issue is that different users use different resolutions so the background image has to be able to accommodate them all without being cut off. I'm not sure how to do this.

Upvotes: 1

Views: 808

Answers (1)

IntelliJ Amiya
IntelliJ Amiya

Reputation: 75788

Set ScaleType fitXY and add android:adjustViewBounds ="true" Please use android:src="@drawable/ instead background .I hope it will helps you.

Upvotes: 2

Related Questions