Fade out an imageview?

thebaldconvict

Member
Licensed User
Longtime User
Hi all,

A quick question if I may, (I have searched a fair while but can't see anything).

I've been using Basic4android for only a few days but am getting to grips with it, its amazing how powerful it is and how I can now not use Java.... anyway...


In my app I've made the splash screen be an imageview that is full screen and a timer runs for 3 seconds before disabling the timer and changing the visible property of the imageview to false.

What I actually wanted was for the imageview to fade to transparent leaving the main app screen in view but I cant find any way to adjust the alpha or transparency settings.


Could anybody please help, this and my little sound problem (not sure how to play click sounds etc) are the last ones before I can release my first app!



Thanks in advance

Tim
 

Roger Garstang

Well-Known Member
Licensed User
Longtime User
Might be other ways, but do you know the background color behind it? If so you could draw over the top of it with a color equal to the background and vary the alpha of the color using a timer or something until it covers the image. Once covered you could then remove the image since it is underneath the object covering it. Once image is gone you could even remove the object you used to cover it.

Might even be able to draw right on the image with a canvas and repeat coloring with the background color at a low percent like 1 and do it 255 times or 2 and do it 128 times, etc which if the calculations are right should cover it.
 
Last edited:
Upvote 0

thebaldconvict

Member
Licensed User
Longtime User
Unfortunately, the background of the view is an image with a coloured pattern on it so there isn't as such a colour to fade too....
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Perhaps you could create another 2-3 versions of your image, which would be designed in such a way that a fade-out effect appears.
 
Upvote 0

thebaldconvict

Member
Licensed User
Longtime User
The only other thing I could think of doing was moving the imageview offscreen before setting it as not visible giving the effect of it sliding off but it seems a bit of a compromise :eek:

Sent from my Galaxy Note using Tapatalk
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
I liked your idea, so I thought I would see if I could write a class quicky to do this. This may be what you wanted, you are welcome to try. Below is a sample of the code in your Activity and attached is the Class code Zipped. You will need B4A 2.02. :D

B4X:
Sub Globals
   Dim MyFade As fade
End Sub
Sub Activity_Create(FirstTime As Boolean)
   'Put your code here
End Sub
Sub Activity_Resume
   MyFade.Initialize(Activity, Me, "1.jpg", 6000, 100)
End Sub
 

Attachments

  • fade.zip
    803 bytes · Views: 582
Upvote 0

thebaldconvict

Member
Licensed User
Longtime User
I liked your idea, so I thought I would see if I could write a class quicky to do this. This may be what you wanted, you are welcome to try. Below is a sample of the code in your Activity and attached is the Class code Zipped. You will need B4A 2.02. :D

B4X:
Sub Globals
   Dim MyFade As fade
End Sub
Sub Activity_Create(FirstTime As Boolean)
   'Put your code here
End Sub
Sub Activity_Resume
   MyFade.Initialize(Activity, Me, "1.jpg", 6000, 100)
End Sub

Thanks Margret, that works really really well :D :sign0098:

One more question, the image is bigger than the screen so that it fits on all devices and I'd made the imageview "fit" the image, using your class its showing full size so the picture doesn't fit.

Is there any way I can change it to fit the screen?


Many thanks again :D


Ahhhh done it, changed the line in the class:

B4X:
   'BitImage.Gravity = Gravity.CENTER
   BitImage.Gravity = Gravity.FILL

That is awesome! Thank you so much!
 
Last edited:
Upvote 0

dclarkchem

Member
Licensed User
Longtime User
I liked your idea, so I thought I would see if I could write a class quicky to do this. This may be what you wanted, you are welcome to try. Below is a sample of the code in your Activity and attached is the Class code Zipped. You will need B4A 2.02. :D

B4X:
Sub Globals
   Dim MyFade As fade
End Sub
Sub Activity_Create(FirstTime As Boolean)
   'Put your code here
End Sub
Sub Activity_Resume
   MyFade.Initialize(Activity, Me, "1.jpg", 6000, 100)
End Sub

Wow, thanks! Exactly what I was looking for ! ! !
 
Upvote 0
Top