francoisg Active Member Licensed User Longtime User May 8, 2013 #1 Hi All, Is it possible to permanently set the alpha of an item to say 0.5 and then only once the user clicks on it it will become fully opaque? I am using: a.InitializeAlpha("a", 0.5, 0.5) a.Duration = 0 'adjust your blinking speed a.RepeatCount = 0 a.Start(btn) i.e. Instead of blinking i want it to stay transparent until clicked on... Regards Francois
Hi All, Is it possible to permanently set the alpha of an item to say 0.5 and then only once the user clicks on it it will become fully opaque? I am using: a.InitializeAlpha("a", 0.5, 0.5) a.Duration = 0 'adjust your blinking speed a.RepeatCount = 0 a.Start(btn) i.e. Instead of blinking i want it to stay transparent until clicked on... Regards Francois
Erel B4X founder Staff member Licensed User Longtime User May 8, 2013 #2 Try this library: http://www.b4x.com/forum/additional...dates/21313-lib-animationplus.html#post123188 Upvote 0
Try this library: http://www.b4x.com/forum/additional...dates/21313-lib-animationplus.html#post123188
francoisg Active Member Licensed User Longtime User May 8, 2013 #3 Hi, thank you for the reply. Is it at all possible to create dynamically (in code) a button, set the button image to display and make it (the button, with the image) say 50% transparent? Maybe using drawable somehow? Upvote 0
Hi, thank you for the reply. Is it at all possible to create dynamically (in code) a button, set the button image to display and make it (the button, with the image) say 50% transparent? Maybe using drawable somehow?
yttrium Active Member Licensed User Longtime User May 8, 2013 #4 francoisg said: Hi, thank you for the reply. Is it at all possible to create dynamically (in code) a button, set the button image to display and make it (the button, with the image) say 50% transparent? Maybe using drawable somehow? Click to expand... This should be possible using a Statelist Drawable, which has an alpha field. Set it to 127. Upvote 0
francoisg said: Hi, thank you for the reply. Is it at all possible to create dynamically (in code) a button, set the button image to display and make it (the button, with the image) say 50% transparent? Maybe using drawable somehow? Click to expand... This should be possible using a Statelist Drawable, which has an alpha field. Set it to 127.
francoisg Active Member Licensed User Longtime User May 8, 2013 #5 Hi, I'm using the following code but (obviously) this does not work with bitmaps: Code: Dim cd As ColorDrawable cd.Initialize(Colors.ARGB(127, 255, 128, 128), 5) Dim sld As StateListDrawable sld.Initialize sld.AddState (sld.State_Disabled, cd) sld.AddState (sld.State_Pressed, cd) sld.AddCatchAllState (cd) btn.Background = sld Any suggestions on how to get it working WITH a bitmap??? Upvote 0
Hi, I'm using the following code but (obviously) this does not work with bitmaps: Code: Dim cd As ColorDrawable cd.Initialize(Colors.ARGB(127, 255, 128, 128), 5) Dim sld As StateListDrawable sld.Initialize sld.AddState (sld.State_Disabled, cd) sld.AddState (sld.State_Pressed, cd) sld.AddCatchAllState (cd) btn.Background = sld Any suggestions on how to get it working WITH a bitmap???
yttrium Active Member Licensed User Longtime User May 8, 2013 #6 francoisg said: Hi, I'm using the following code but (obviously) this does not work with bitmaps: Code: Dim cd As ColorDrawable cd.Initialize(Colors.ARGB(127, 255, 128, 128), 5) Dim sld As StateListDrawable sld.Initialize sld.AddState (sld.State_Disabled, cd) sld.AddState (sld.State_Pressed, cd) sld.AddCatchAllState (cd) btn.Background = sld Any suggestions on how to get it working WITH a bitmap??? Click to expand... You should be sure to also set sld.State_Enabled, the default button value. As for the bitmap, perhaps something using ABExtDrawing would be more akin to your liking: Code: Dim ed As ABExtDrawing Dim p As ABPaint p.SetAlpha(127) ed.drawBitmap You should be able to figure out the rest of that, just be sure to use p as the paint for ed.drawBitmap. Basically just draw the bitmap loaded from an image to a new bitmap, and when drawing it use that paint to make it partially transparent. Then set the button to that bitmap. Last edited: May 8, 2013 Upvote 0
francoisg said: Hi, I'm using the following code but (obviously) this does not work with bitmaps: Code: Dim cd As ColorDrawable cd.Initialize(Colors.ARGB(127, 255, 128, 128), 5) Dim sld As StateListDrawable sld.Initialize sld.AddState (sld.State_Disabled, cd) sld.AddState (sld.State_Pressed, cd) sld.AddCatchAllState (cd) btn.Background = sld Any suggestions on how to get it working WITH a bitmap??? Click to expand... You should be sure to also set sld.State_Enabled, the default button value. As for the bitmap, perhaps something using ABExtDrawing would be more akin to your liking: Code: Dim ed As ABExtDrawing Dim p As ABPaint p.SetAlpha(127) ed.drawBitmap You should be able to figure out the rest of that, just be sure to use p as the paint for ed.drawBitmap. Basically just draw the bitmap loaded from an image to a new bitmap, and when drawing it use that paint to make it partially transparent. Then set the button to that bitmap.
Informatix Expert Licensed User Longtime User May 8, 2013 #7 francoisg said: Hi All, Is it possible to permanently set the alpha of an item to say 0.5 and then only once the user clicks on it it will become fully opaque? I am using: a.InitializeAlpha("a", 0.5, 0.5) a.Duration = 0 'adjust your blinking speed a.RepeatCount = 0 a.Start(btn) i.e. Instead of blinking i want it to stay transparent until clicked on... Click to expand... As Erel said, you can use my AnimationPlus library to set a transparency level: a.InitializeAlpha(myButton, 0.5, 0.5) a.PersistAfter = True a.Start(myButton) Then, in the Click event: a.InitializeAlpha(myButton, 0.5, 1) a.Start(myButton) This code allows to do a smooth transition from transparent to opaque. If you don't care of this transition, you can use my Accelerated Surface library. There's a function called AlterColors in the class AS_ImageUtils that allows to modify the transparency (+ hue and saturation) of a bitmap with an optimized algorithm (it can be used in real-time). Upvote 0
francoisg said: Hi All, Is it possible to permanently set the alpha of an item to say 0.5 and then only once the user clicks on it it will become fully opaque? I am using: a.InitializeAlpha("a", 0.5, 0.5) a.Duration = 0 'adjust your blinking speed a.RepeatCount = 0 a.Start(btn) i.e. Instead of blinking i want it to stay transparent until clicked on... Click to expand... As Erel said, you can use my AnimationPlus library to set a transparency level: a.InitializeAlpha(myButton, 0.5, 0.5) a.PersistAfter = True a.Start(myButton) Then, in the Click event: a.InitializeAlpha(myButton, 0.5, 1) a.Start(myButton) This code allows to do a smooth transition from transparent to opaque. If you don't care of this transition, you can use my Accelerated Surface library. There's a function called AlterColors in the class AS_ImageUtils that allows to modify the transparency (+ hue and saturation) of a bitmap with an optimized algorithm (it can be used in real-time).
francoisg Active Member Licensed User Longtime User May 10, 2013 #8 Thank you! The hint about using ABExtDrawing worked 100% !!!! Upvote 0