0

In basic4android, when an Activity starts, it pops out from the corner of the screen on my phone.

I tried creating XML files for animations between Activities, but still Activities start with my animation along that annoying pop up animation.

I want to get rid of that and use my custom animation.

I'm using this function and two XML files to create an animation:

Sub ListView1_ItemClick (Position As Int, Value As Object)
    StartActivity(Value)
    SetAnimation("file1", "file2")
End Sub

Sub SetAnimation(InAnimation As String, OutAnimation As String)
    Dim r As Reflector
    Dim package As String
    Dim In, out As Int
   package = r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
    In = r.GetStaticField(package & ".R$anim", InAnimation)
    out = r.GetStaticField(package & ".R$anim", OutAnimation)
    r.Target = r.GetActivity
    r.RunMethod4("overridePendingTransition", Array As Object(In, out), Array As String("java.lang.int", "java.lang.int"))
End Sub

and XML files

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="400"
        android:fromAlpha="0.0"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:toAlpha="1.0" />

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
   android:duration="400"
        android:fromAlpha="1.0"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:toAlpha="0.0" />

i'm using version 5.0.2 of b4a can this be the case?

1 Answers1

0

This post from the b4x forums says you have to call SetAnimation right after either calling startActivity() or finish(). As your animation seems to work I guess you're not calling it immediately after calling one of these methods, so the default animation is still applied.

Paul M.
  • 82
  • 1
  • 7