I have problem translating very large picture in Android. What I would like is my picture's height to be set screen's height and to show the rest of width not changing image's ratio. Since my image is very wide, not whole would be shown for first, but it would with translation, I would slowly move it over x axis.
I think there must be simple way to do this, but I'm struggling already 6 hours watching all question here and other, trying to find where I'm mistaking because I can't show my picture like that it's shown just as much as it can be shown - height set to full screen's height and width just as much as it fit and then to show other part of picture's width as it's translating.
My code:
import android.os.Bundle;
...
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView imageView = (ImageView) findViewById (R.id.background);
ObjectAnimator mover = ObjectAnimator.ofFloat(imageView, "translationX", 0, 1000f);
mover.setDuration(10000);
mover.start();
}
}
and simple layout:
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/background"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:src="@drawable/background"
android:scaleType="centerCrop">
The thing with scaleType with centerCrop and center is that they same do both - they maintain image's ratio and height is screen's height, but the image is cut and when I make animation, immediately starts to go white screen as if there is no more width of picture. centerInside is not helping either.
Can you please help me? I already lost so many hours on this. I would be really thankful.