Android Question Animation on clikking image/buttom

Schakalaka

Active Member
Licensed User
Longtime User
Hello,
how is posible create this kind of animation on clikking?

B4X:
https://drive.google.com/file/d/1mrex9JlwOJ8c_rird7pIdp4N0IXXEDOO/view?usp=sharing
 

Star-Dust

Expert
Licensed User
Longtime User
Yes. You can find something similar in the forum. It was made a few years ago.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
as you can see the coin animation is not proportional so its not only width and height that is changing.
it is a array of sprites that are selected in a fix interval.
basically all you need is to have the animation sprites and loop them in a timer event (or using sleep()) when the user is clicking the coin.
the coin can be an imageview and all you do is changing the bitmap inside the imageview.

you have many many examples in the forum.
have a look at this:


here is an example of how to use sprites

it is drawn in a canvas but for your need an imageview is good anough
 
Last edited:
Upvote 0

ilan

Expert
Licensed User
Longtime User
a very simple example


1716468017208.png



 
Upvote 0

Schakalaka

Active Member
Licensed User
Longtime User
my rude design solution:

1716483293802.png


code:

B4X:
Private Sub btn_button_Click
    ImageView1.SetLayoutAnimated(200,ImageView1.Left,ImageView1.Top- 3%x,ImageView1.Width,ImageView1.Height)
    Sleep(100)
    ImageView1.SetLayoutAnimated(200,ImageView1.Left,ImageView1.Top+ 3%x,ImageView1.Width,ImageView1.Height)
End Sub

Private Sub btn_right_Click
    ImageView1.SetLayoutAnimated(200,ImageView1.left - 3%x,ImageView1.Top,ImageView1.Width,ImageView1.Height)
    Sleep(100)
    ImageView1.SetLayoutAnimated(200,ImageView1.left + 3%x,ImageView1.Top,ImageView1.Width,ImageView1.Height)
End Sub

Private Sub btn_left_Click
    ImageView1.SetLayoutAnimated(200,ImageView1.Left+ 3%x,ImageView1.Top,ImageView1.Width,ImageView1.Height)
    Sleep(100)
    ImageView1.SetLayoutAnimated(200,ImageView1.Left- 3%x,ImageView1.Top,ImageView1.Width,ImageView1.Height)
End Sub

Private Sub btnTop_Click
    ImageView1.SetLayoutAnimated(200,ImageView1.Left,ImageView1.Top+ 3%x,ImageView1.Width,ImageView1.Height)
    Sleep(100)
    ImageView1.SetLayoutAnimated(200,ImageView1.Left,ImageView1.Top- 3%x,ImageView1.Width,ImageView1.Height)
End Sub
 
Upvote 0
Top