How to show a splash screen for 3 seconds on Android? -



How to show a splash screen for 3 seconds on Android? -

i splash image begin , remain 3 seconds, , disappear , go on or replaced rest of layout in main.xml.

this code:

main.java

public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); setcontentview(r.layout.main); imageview splash = (imageview) this.findviewbyid(r.id.splash);

main.xml

<?xml version="1.0" encoding="utf-8"?> <!-- margin=0px, padding=20px --> <!--textview padding=10dp, textsize=16sp--> <!--px=pixel, dp=density indepen sp=scale indepen fontsize preference --> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <imageview android:id="@+id/splash" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/splash2"/> <imageview android:id="@+id/myimageview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/bg_main"/> <imageview android:id="@+id/myimageview0" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/bar_top"/> <!-- <textview android:id="@+id/textitem" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:paddingtop="10dp" android:paddingleft="110dp" android:background="#00000000" android:textcolor="#ffffffff" android:textsize="22sp" android:text="find car" android:enabled="false" > --> <tabhost android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <relativelayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="3dp"> <framelayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" /> <tabwidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignbottom = "@android:id/tabcontent" /> </relativelayout> </tabhost> </relativelayout>

you can this

imageview splash = (imageview) this.findviewbyid(r.id.splash); splash.postdelayed(new runnable(){ splash.setvisibility(view.gone); }, 3000);

or maybe add together animation invoking method (from android docs) instead of setting visibility gone directly

private void fadesplashout() { // set content view 0% opacity visible, visible // (but transparent) during animation. mcontentview.setalpha(0f); mcontentview.setvisibility(view.visible); // animate content view 100% opacity, , clear animation // listener set on view. mcontentview.animate() .alpha(1f) .setduration(mshortanimationduration) .setlistener(null); // animate loading view 0% opacity. after animation ends, // set visibility gone optimization step (it won't // participate in layout passes, etc.) splash.animate() .alpha(0f) .setduration(mshortanimationduration) .setlistener(new animatorlisteneradapter() { @override public void onanimationend(animator animation) { splash.setvisibility(view.gone); } }); }

android

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -