Remove image after loading screen with animation, Android -
i'm trying show splash screen between activities. i'm using handler loads imageview sets visibility gone after amount of time.
i wanted make bit more fancy , animate loadanimation. problem i'm running once handler ends animation stops not remove loading image screen. instead placed background whole activity.
i know how remove splash image after handler stops.
below code:
private static final long splashtime = 3000; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main) imageview splash = (imageview)findviewbyid(r.id.splashscreen); final animation = animationutils.loadanimation(getbasecontext(),r.anim.progress_anim); a.setduration(1000); splash.startanimation(a); new handler().postdelayed(new runnable(){ @override public void run() { a.cancel(); splash.setvisibility(view.gone); } }, splashtime); }
xml splash image:
<imageview android:id="@+id/splashscreen" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/loading_circle" android:layout_gravity="center" />
just declare splash globally , not in oncreate().
Comments
Post a Comment