I made a splash screen with react-native-splash-screen and it works fine now want to rotate an image ( infinite rotation ) I tried this code .. but the app keeps crashing before opens is there any way to achieve this?
res/anim/rotate.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/cycle_interpolator">
<rotate android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="5000" />
</set>
res/layout/launch_screen.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff">
<ImageView
android:src="@drawable/launch_screen"
android:layout_width="fill_parent"
android:layout_centerVertical="true"
android:layout_height="140dp" />
<ImageView
android:id="@+id/imgvw"
android:layout_alignParentBottom="true"
android:layout_marginBottom="175dp"
android:src="@drawable/loading"
android:layout_width="fill_parent"
android:layout_centerVertical="true"
android:layout_height="80dp"
/>
<ImageView
android:layout_alignParentBottom="true"
android:src="@drawable/copyrights"
android:layout_width="fill_parent"
android:layout_marginBottom="30dp"
android:layout_height="20dp" />
</RelativeLayout>
mainActivity.java
...other imports/
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public class MainActivity extends ReactActivity {
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
SplashScreen.show(this);
ImageView img = (ImageView)findViewById(R.id.imgvw);
//Animation aniRotate = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.rotate);
// img.startAnimation(aniRotate);
return new MainActivityDelegate(this, getMainComponentName());
}
...default app code.
}
i got this error :
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object