How to move image up and down continuously using translate animation in android? -


I have successfully used a side animation using the translation animation which implies that the image above Goes down. Here's the code:

  Private Image View mScanner; Private Animation M Animation; Override public null on @reate (bundle saved instainstate) {super.naught (savedinstenstate); SetContentView (R.layout.main); MScanner = (ImageView) findViewById (R.id.Scanner); M animation = new translation animation (0, 0, 0, 500); MAnimation.setDuration (10000); MAnimation.setFillAfter (true); MAnimation.setRepeatCount (-1); MAnimation.setRepeatMode (Animation.REVERSE); MScanner.setAnimation (mAnimation); MScanner.setVisibility (View.VISIBLE); }   

Now I want the image to reach the bottom of the screen, it should start returning to the top. How can I go about doing this?

Note: completed the reverse mode. Please see the code. But now the problem is that when it goes upwards from the bottom, it leaves leaves, how to remove these lines like an attached image? screenshot

Modify your code according to:

  mScanner.setVisibility (see Visual.); MAnimation = new translation permission (translation permission. Abolt, 0f, translation invocation. Abosolute, 0f, translation permission .RELATIVE_TO_PARENT, 0f, translation permission .RELATIVE_TO_PARENT, 1.0f); MAnimation.setDuration (10000); MAnimation.setRepeatCount (-1); MAnimation.setRepeatMode (Animation.REVERSE); MAnimation.setInterpolator (New LinearInterpolator ()); MScanner.setAnimation (mAnimation);   

And instead of using XML instead of the image please see the code below and place it on your ImageView src.

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Size xmlns: Android = "http://schemas.android.com/apk/res/android" Android: Size = "Row" & gt; & Lt; Solid Android: Color = "# 0000ff" / & gt; & Lt; Size Android: width = "480dp" Android: height = "10dp" /> & Lt; Corners Android: Radius = "1dp" /> & Lt; Stroke Android: width = "3dp" Android: color = "# 000000" /> & Lt; / Size & gt;   

I hope this will help you.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -