I need to cause a graphic of a “pushed” button to appear as an overlay on a “released” button graphic.
The normal Button view almost works for me, using the StatelistDrawable property and setting the Enabled Drawable bitmap to an all-transparent graphic image, and setting the Pressed Drawable to the “pushed” graphic image. This works fine with the “pushed” image appearing when the button is touched. There is no visible flicker.
But the button images I have are closely spaced and in complex shapes and attempting to tile the images into rectangular buttons would result in (greatly) overlapped buttons. So my alternative plan was to display the “pushed” image using a larger view as a container for the image and use a smaller transparent button view on top of the graphic image as the touchable area. When the transparent button is pushed (down event) the view containing the image is made visible. And when the transparent button is released (up event) the view containing the image is made invisible. This also works fine, except for a “flicker”.
When I change a view from invisible to visible (.Visible=True) the graphic becomes visible but seems to briefly “flicker” like the image is being drawn, erased, and the drawn again. I would guess that this occurs in about a quarter second. This does not sound like a big deal, but it is actually quite distracting.
I have tried using various types of views as the container for the graphic: Button, ImageView, Label, Panel. They all exhibit the “flicker”.
I have tried using DoEvents to cause the graphic to update after being set to visible.
I tried adding logical flags to prevent multiple down events, if that was the issue.
I boiled the issue down to a very simple example using two button views. The buttons use the normal defaults set by the VisualDesigner, including DefaultDrawable. In the Down event for the first button the second button is set to Visible=True. In the Up event for the first button the second button is set to Visible=False.
The image of the second button appears and flickers when it is set to Visible=True.
The target is a Nexus 10 tablet with Android 5.1
I have spent several hours searching for a solution in the forums and I apologize if this issue is already known or solved. Any assistance will be appreciated even if only to point me in the right direction.
Thanks.
Sub Process_Globals
End Sub
Sub Globals
Private Test_Button As Button
Private Visible_Invisible As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Test")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Test_Button_Down()
Visible_Invisible.Visible = True
' Visible_Invisible becomes visible but briefly flickers
End Sub
Sub Test_Button_Up()
Visible_Invisible.Visible = False
End Sub
The normal Button view almost works for me, using the StatelistDrawable property and setting the Enabled Drawable bitmap to an all-transparent graphic image, and setting the Pressed Drawable to the “pushed” graphic image. This works fine with the “pushed” image appearing when the button is touched. There is no visible flicker.
But the button images I have are closely spaced and in complex shapes and attempting to tile the images into rectangular buttons would result in (greatly) overlapped buttons. So my alternative plan was to display the “pushed” image using a larger view as a container for the image and use a smaller transparent button view on top of the graphic image as the touchable area. When the transparent button is pushed (down event) the view containing the image is made visible. And when the transparent button is released (up event) the view containing the image is made invisible. This also works fine, except for a “flicker”.
When I change a view from invisible to visible (.Visible=True) the graphic becomes visible but seems to briefly “flicker” like the image is being drawn, erased, and the drawn again. I would guess that this occurs in about a quarter second. This does not sound like a big deal, but it is actually quite distracting.
I have tried using various types of views as the container for the graphic: Button, ImageView, Label, Panel. They all exhibit the “flicker”.
I have tried using DoEvents to cause the graphic to update after being set to visible.
I tried adding logical flags to prevent multiple down events, if that was the issue.
I boiled the issue down to a very simple example using two button views. The buttons use the normal defaults set by the VisualDesigner, including DefaultDrawable. In the Down event for the first button the second button is set to Visible=True. In the Up event for the first button the second button is set to Visible=False.
The image of the second button appears and flickers when it is set to Visible=True.
The target is a Nexus 10 tablet with Android 5.1
I have spent several hours searching for a solution in the forums and I apologize if this issue is already known or solved. Any assistance will be appreciated even if only to point me in the right direction.
Thanks.
Sub Process_Globals
End Sub
Sub Globals
Private Test_Button As Button
Private Visible_Invisible As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Test")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Test_Button_Down()
Visible_Invisible.Visible = True
' Visible_Invisible becomes visible but briefly flickers
End Sub
Sub Test_Button_Up()
Visible_Invisible.Visible = False
End Sub