Question

I should display an animation that draws line from left to right. Please look at following image.

  • First layer is background (whole image without root lines and country names)
  • Second layer is lines and country names.

I can use alpha animation in following way in my activity:

mIvRoot = (ImageView) findViewById(R.id.ivRoot);
ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(mIvRoot, "alpha", 0f, 1f);
alphaAnim.setDuration(2000);
alphaAnim.start();

Although it works fine, however alpha applies to whole image. The thing that I'm looking for instead is alpha applies from left to right. Therefore, user feels lines are drawing.

Any suggestion would be appreciated. Thanks

enter image description here

Was it helpful?

Solution 2

Even though i didn't understand why you're not actually drawing those lines, you may want to look at this post by Romain Guy that he also made something similar (Actually almost same :))

OTHER TIPS

I fixed temporarily my problem in a bl.sht way. Please share with me your idea to fix this way.

I placed another white view (since my background is white) on top of root image and assigned it translation animation instead of using alpha animation Like this:

<View
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@color/White"
                android:id="@+id/viCover"
                android:layout_alignTop="@+id/ivRoot"
                android:layout_alignBottom="@+id/ivRoot"
                android:layout_alignLeft="@+id/ivRoot"
                android:layout_alignRight="@+id/ivRoot"
                android:layout_marginLeft="200dp"/> 

and code:

ObjectAnimator transRootAnim = ObjectAnimator.ofFloat(mViCover, "translationX", 0f, 1500f);
transRootAnim.setDuration(3000);
transRootAnim.start();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top