Hii everybody,
I want to give my custom view animation like button click.
I want to give my custom view animation like button click.
Public Sub DesignerCreateView (Base As Panel, Lbl As Label, Props As Map)
'mBase = Base
mHeight = Base.Height
Base.Color = Colors.Red
Dim cd As ColorDrawable
cd.Initialize(Props.Get("Color"),20)
Base.Background = cd
mBase.Initialize("mBase")
mButton.Initialize("mButton")
Base.AddView(mBase,0,0,Base.Width,mHeight)
mBase.AddView(Lbl,0,0,Base.Width,mHeight)
mBase.Background = cd
If Props.Get("NoDefaultColor")="N" Then
mBase.Color = Colors.RGB(191,16,232)
Else
mBase.Color = Props.Get("Color")
End If
If Props.Get("NoDefaultFontSize")="N" Then
Lbl.TextSize = 14
Else
Lbl.TextSize = Props.Get("FontSize")
End If
If Props.Get("NoDefaultTextColor")="N" Then
Lbl.TextColor = Colors.Black
Else
Lbl.TextColor = Props.Get("TextColor")
End If
Lbl.Text = Props.Get("Text")
End Sub
Private Sub mBase_Click
'mBase.SetVisibleAnimated(1000,True)
If SubExists(mCallBack,mEventName & "_Click") Then
CallSub(mCallBack,mEventName & "_Click")
End If
End Sub
Public Sub DesignerCreateView (Base As Panel, Lbl As Label, Props As Map)
mBase = Base
Dim obj As Reflector
obj.Target = mBase
obj.SetOnClickListener("mBase_Click")
Dim cd As ColorDrawable
cd.Initialize(Props.Get("Color"),20)
mBase.Background = cd
If Props.Get("NoDefaultColor")="N" Then
mBase.Color = Colors.RGB(191,16,232)
Else
mBase.Color = Props.Get("Color")
End If
If Props.Get("NoDefaultFontSize")="N" Then
Lbl.TextSize = 14
Else
Lbl.TextSize = Props.Get("FontSize")
End If
If Props.Get("NoDefaultTextColor")="N" Then
Lbl.TextColor = Colors.Black
Else
Lbl.TextColor = Props.Get("TextColor")
End If
Lbl.Text = Props.Get("Text")
End Sub
There is Ripple Effect lib available. You can use it to create similar effect.yeah it also great idea, but I want some other solution without adding button.
I wrote the object type badly, copy thisno it not showing any effect
Private Sub mBase_Click (viewtag as object)
'mBase.SetVisibleAnimated(1000,True)
If SubExists(mCallBack,mEventName & "_Click") Then
CallSub(mCallBack,mEventName & "_Click")
End If
End Sub
'mBase = Base
mBase.Initialize("mBase")
Sub Class_Globals
' ...
Private mBase As Panel
Private mButton As Button
End Sub
Public Sub DesignerCreateView (Base As Panel, Lbl As Label, Props As Map)
mBase = Base
mButton.Initialize("mButton")
Base.AddView(mButton, 0, 0, Base.Width, Base.Height)
mButton.Background = Base.Background
mButton.Text = Lbl.Text
mButton.TextSize = Lbl.TextSize
End Sub
Private Sub mButton_Click
Dim Duration As Int = 50
Dim Offset As Float = 1.05
Wait For (Animation (mBase, Duration, mBase.Left * Offset, mBase.Top * Offset)) Complete (Dummy As Boolean)
Wait For (Animation (mBase, Duration, mBase.Left / Offset, mBase.Top / Offset)) Complete (Dummy As Boolean)
CallSub(mCallBack, mEventName & "_Click")
End Sub
Private Sub Animation (VW As View, duration As Long, X As Int, Y As Int) As ResumableSub
VW.SetLayoutAnimated(duration, X, Y, VW.width, VW.Height)
Sleep(duration)
Return True
End Sub
Ripple effect library work for me.There is Ripple Effect lib available. You can use it to create similar effect.
Fortunatamente me lo sono messo da solo un "Like" .[Well done; I like this post]
Note:
d) you don't need to check if the event sub exists;
Download my example, remove Sub cvMyButton1_Click from the Main and tell me if your app crashes.If you Don't check for the sub existance (this sub you are checking is not the one in the Library it self) and if it doesn't exist, it will throw an error and crash the app