Android Question Animation Of Layout On Loading Vs Non-Layout Views

RichardN

Well-Known Member
Licensed User
Longtime User
When a layout is loaded into the activity it is animated in an eye-catching manner, sweeping in from the top-left hand corner of the screen. It looks pretty good.

I recently modified a project to add some 'clear' controls to the EditText boxes rather like the ones used in iOS. An image of a clear button and a panel to catch the click event are added in code over each EditText. The panel 'click' event is captured by a generic click sub using the Sender/Tag method to find the view that was clicked.

Unfortunately when the layout is loaded the views added in code appear immediately in their final positions...... long before the animation of the layout is complete so it all looks rather scrappy.

I presume there is a method to suppress the animation on layout loading?

If I want to keep the layout animation.... how to keep the clear buttons hidden until the animation is complete?
 

Cableguy

Expert
Licensed User
Longtime User
If you can add the custom views by Code, do it after the loadLayout...
Also, you may try to add the custom views using a dedicated sub, and call that sub using the callsubdelayed after the loadLayout
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I presume there is a method to suppress the animation on layout loading?
NO. There is NO Method. Just set the AnimationDuration of all your layouts to 0 to remove the animation.
 
Upvote 0

RichardN

Well-Known Member
Licensed User
Longtime User
Thanks for the suggestions but none appear to work.

Using CallSubDelayed the views added with code are visible long before the layout animation has finished so the problem remains.

Using:
B4X:
Sub Activity_Create(FirstTime As Boolean)

    Dim count As Int
   
    For count = 0 To Activity.NumberOfViews -1
        Dim v As View = Activity.GetView(count)
        v.SetLayoutAnimated(0,v.Left,v.Top,v.Width,v.Height)
    Next
   
    Activity.LoadLayout("main.bal")       

End Sub

The AnimationDuration property cannot be set in the designer so the layout appears to be animated on load with a default value.

No matter if you execute the SetLayoutAnimated code before OR after loading the layout the animation cannot be suppressed.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
A method could be to set internal views invisible, enable a timer which interval is set same as the animation duration and set all views visible in the timer event routine (disable the timer in this routine, of course)

It's not stylish but it should work.
 
Upvote 0
Top