Android Tutorial Android views animation tutorial

kl3inh3nz

Member
Licensed User
Longtime User
... I did intent to include AnimationSet object that will allow animating multiple animations concurrently...

This answer was from 2010, so i would like to know if it is still not possible to run multiple animations?
 

PharCyDeD

Active Member
Licensed User
Longtime User
Can you make button 6 move to a specified location without using dip? Like using .Top and .Left?
 

PharCyDeD

Active Member
Licensed User
Longtime User
Is there any way to determine the 'dip' of a certain area then? I have a lot of imageviews that I want to move with this animation due to its very visual nature, but the location they are moved too is determined at random. I have a sub that currently handles all of this, but in the sub imageviews move using '.Top' & '.Left'. Can I convert those values to dip somehow so I can use this animation?
 

gkumar

Active Member
Licensed User
Longtime User
How to display the animated progress bar

I need to display the progress bar with some animation instead of default spinner progressbar. I have around 15 series of images to be shown as animated progressbar. Anybody worked on this kind of progressbar?
 

Vabz

New Member
When i do declare a1 as a "Animation", the program is not picking it up. Type Animation is not recognised on B4U. Can anyone tell me what is wrong?:sign0085:
 

Vabz

New Member
Buttons

In this tutorial, Do the Buttons need to be declared first because they are not being recognized when i'm trying. :sign0085:
 

sioconcept

Active Member
Licensed User
Longtime User
Can we make 2 animations in same time as :

B4X:
      anim1.InitializeRotateCenter("", Degres, Degres - Rnd(1, 90), dice)
      anim1.InitializeTranslate("", 0, 0, 300dip, 200dip)
      anim1.Duration = 1000
      anim1.Start(dice)

?
 

noclass1980

Active Member
Licensed User
Longtime User
Hi, I'm very new to Basic4Android but enjoying it hugely so far! I've managed to set up labels that appear dependent on a variable value but would like to use animation to make them fade in/translate etc. I have a routine that makes visible 12 labels but the animation on the almost all the labels appear before the first label completes its animation. How is the AnimationEnd sub called to make sure the program effectively "pauses" until the animation is complete?
part of my code is
B4X:
Dim lblflyin As Animation ' in process Globals
lblflyin.InitializeAlpha("", 1, 0) ' in Activity Create (First time as Boolean)

Sub Animate_St
Dim Reader As TextReader
Reader.Initialize(File.OpenInput(File.DirAssets,"text_st.txt"))
Dim line As String
For i = 0 To 2
line=Reader.ReadLine
lblSt0.Initialize("")
lblSt1.Initialize("")
lblSt2.Initialize("")
Select  i
Case 0
Activity.AddView(lblSt0,Imgv_Model1.Left+20,Imgv_Model1.Top+50,400,200)
lblSt0.Text=line
lblSt0.TextSize=20
lblSt0.TextColor=Colors.Green
lblSt0.Tag=lblflyin
lblflyin.Duration=1000
lblflyin.Start(lblSt0)
Case 1
Activity.AddView(lblSt1,Imgv_Model1.Left+20,Imgv_Model1.Top+75,400,200)
lblSt1.Text=line
lblSt1.TextSize=20
lblSt1.TextColor=Colors.Green
lblSt1.Tag=lblflyin
lblflyin.Duration=1000
lblflyin.Start(lblSt1)
Case 2
Activity.AddView(lblSt2,Imgv_Model1.Left+20,Imgv_Model1.Top+100,400,200)
lblSt2.Text=line
lblSt2.TextSize=20
lblSt2.TextColor=Colors.Green
lblSt2.Tag=lblflyin
lblflyin.Duration=1000
lblflyin.Start(lblSt2)
End Select
Next
Reader.Close
End Sub

so it reads a text file and I want each label to fade in over 1 second.

Any suggestions?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Your code can be significantly shorter. See this example: Tick-Tack-Toe: working with arrays of views

You should use 'dip' units when specifying dimensions (in Activity.AddView).

You cannot wait for an event. You should start the next animation in the AnimationEnd event of the previous one. See how Button6 handled in the Animations example.
 

noclass1980

Active Member
Licensed User
Longtime User
Thank you for the quick reply. I think I understand your comment. Do you mean that I should put my labels in an array like in button 6 but with the same animation (fade)? even though the animation is started by clicking a button, is the Sender identifier the label name in my case? That is, if it is lblSt0 then it triggers the next animation in the AnimationEnd sub? Finally, how does the Button 6 animation know to run the Animation_AnimationEnd sub? sorry for appearing stupid! I'll rewrite my code along the lines of the Tick-Tack-Toe to shorten it as you suggest. Thanks again.
 

ykucuk

Well-Known Member
Licensed User
Longtime User
help for newbie

hello,

i start work with animation.

i can move some view to x1 to x2 or y1 to y2

my problem is when view arrive to target point it comes back to original point (x1)

any idea ?
 

Pintinho

Member
Licensed User
Longtime User
Hi Erel and all
First of all, I would like to congratulate you on the fantastic software and forum you have running here - although this is my first question on the forum, I have been profitting from all the tips in this forum to sort my problems. And I have sucessfully completed my first app, a translation from an IOS app, for a friend of mine. It has loads of animations, so I have been playing around Animation and timers to accomplish the "translation".

There is unfortunately that last error that it seems that I cannot solve (unfortunately I cannot publish here my app, since it belongs to this friend of mine but hopefully you will understand this issue and might be able to help me):

On my screen, I have 15 buttons defined, with an image as background and a letter.
A word is said, chosen randomly from a list and then the sounds of the letters is said one by one, for the kid to press it.
If it takes too long, after 3 times repeating the letter sound and the kid has not managed to match the letter to the sound, I create an animationScaleCenter to highlight to the kid which letter he/she should press.

The problem I am having is that the first word, everything works fine but then the second word, the first letter image gets truncated after the animationScaleCenter

Please refer to the screenshots
the Original screen shot is how the button should look like after the scale
B4X:
  'Define animation
   animLettScale.InitializeScaleCenter("animBtnReset",1, 1, 1.2, 1.2, btnSel)
   animLettScale.RepeatCount = 0
   animLettScale.Duration = 200
And the second screen shot is what happens with my image on letter M

On the animBtnReset_AnimationEnd I try to reset the buttons to their original statuz but to no avail.

Can you see what is happening here? i.e., has this kind of thing has happened before?
I know that this is very little information for you to help me but I really cannot post the application here.

Thanks for any help anyone can give me!
Best regards
Sofia
 

Attachments

  • Original Screen lr.png
    173.8 KB · Views: 486
  • After M selected lr.png
    171.6 KB · Views: 478
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…