views:

65

answers:

2

I can't seem to rotate properly an image on the entire screen. The problem is that when the image rotates, you can see the background in some areas. I want the image to fill the screen also when it rotates. Here is the layout. I've tried different scale types without success.

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ImageView
        android:id="@+id/image"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="centerCrop" />
</LinearLayout>

And here is the code that I am using.

image = (ImageView) findViewById(R.id.image);
image.setBackgroundResource(R.drawable.back_big);
rot = AnimationUtils.loadAnimation(this, R.anim.rotation);
image.startAnimation(rot);

I start the animation in onResume. As I said, the image rotates but there are background areas when it does rotate. I've tried using images much bigger than the screen but still it doesn't do what I want. I don't care that outer regions of the image are not visible. I just want the rotation to fill the screen. I guess ImageView sets its width and height initially and then, when it rotates, it uses those dimensions. Is there a better way to do this?

A: 

You are setting the scaleType of your ImageView to "centerCrop". Unfortunatly there isn't good documentation on the exact meaning of the different scaleTypes, but the name implies that the image is centered on the screen and cropped to the exact size of the ImageView. Thus, when you begin to rotate you will see background areas.

Try chaging the scaleType to just "center".

Mayra
I've already tried all scaleTypes but without success. I think ImageView sets the image's initial width and height to the width and height of the screen and then, when it rotates, it doesn't change the image size dinamically. So I don't think it matters the scaleType.
kaciula
A: 

After looking more at the problem, I don't think it's possible to achieve what I want. If it is possible, then it is too complicated and it's not worth it.

kaciula