Hick
Hick

Reputation: 36394

Image doesn't scale properly in Android.

I'm using a xml drawable:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/splashscreen"
    android:tileMode="disabled" android:gravity="top" >
</bitmap>

this is my imageView in the layout:

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

    <ImageView
        android:id="@+id/splash_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitXY"
         />

</RelativeLayout>

but no matter what I do, it doesn't fit the screen, and only appears in the centre as a small image. Where am I going wrong?

Upvotes: 0

Views: 253

Answers (2)

m.Ling
m.Ling

Reputation: 296

Maybe not the best solution since different devices has different resolutions, but "wrap_content" will display the image in its original resolution.

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

        <ImageView
            android:id="@+id/splash_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/splashscreen"
        />
    </RelativeLayout>

Upvotes: 1

Vikas Rathod
Vikas Rathod

Reputation: 384

Try using fill_parent Each device have different screen size so you need to make different splash image for each size and resolution i guess the problem is you are using image of small size(height width) and the display is big so you need to scale image to fit to display size, this might pixelate the image

Upvotes: 0

Related Questions