Reputation: 31
I am working with my splash screen. I want to have a animating imageview (from left to right). My code really works but the scrolling starts with black color..
What I want to is start the animating from the entire image.
For clear understanding here is my screenshot:
My problem:
My target output
public class splash extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
ImageView img_animation = (ImageView) findViewById(R.id.img_animation);
TranslateAnimation animation = new TranslateAnimation(0, 720, 239, 0);
animation.setDuration(10000);
animation.setFillEnabled(true);
img_animation.startAnimation(animation);
}
}
Layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".Animation" >
<ImageView
android:id="@+id/img_animation"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/splash_1"
android:scaleType="centerCrop" />
</RelativeLayout>
Upvotes: 2
Views: 118
Reputation: 11
Use FrameLayout for positioning imageview to start of view and get imageview width = y and screen width = x then animate y-x.
You can use ObjectAnimator. This nineoldandroid library and its pretty same with default android Object animator.
AnimatorSet set = new AnimatorSet();
long scaleXAmount = y - x; (I mentioned it on above)
set.playTogether(
ObjectAnimator.ofFloat(view, "translationX", 0, scaleXAmount )
);
set.setDuration(800).start();
Upvotes: 1
Reputation: 1170
I think if set width of both RelativeLayout and ImaveView to wrap_content and set adjustViewBound of imaveview "true" it would work
Upvotes: 0