Android Boot page Splash design

Source: Internet
Author: User

The Android_splash boot page is an animated page that describes some of the app's features when the app is first installed, giving users a general idea of what the app does. When the user first installs a boot page, the next time the user starts, it will go directly to the main page.

Sputils.java

Package Com.zwb.splashdemo.utils;import Android.content.context;import android.content.sharedpreferences;/** * Class Description: Sharedpreferences Tool class * ZWB * Time: 16-5-7 11:32 * Email: [email protected] */public class Sputils {private static final    String spfilename = "App"; public static string GetString (context context, String strkey) {sharedpreferences setpreferences = Context.getshar        Edpreferences (Spfilename, context.mode_private);        String result = setpreferences.getstring (strkey, "");    return result;         } public static string getString (context context, string strkey, String strdefault) {         Sharedpreferences setpreferences = context.getsharedpreferences (Spfilename, context.mode_private);        String result = setpreferences.getstring (strkey, Strdefault);    return result; } public static void Putstring (context context, string strkey, String strdata) {sharedpreferences activityprefErences = Context.getsharedpreferences (Spfilename, context.mode_private);        Sharedpreferences.editor Editor = Activitypreferences.edit ();        Editor.putstring (strkey, strdata);    Editor.commit (); The public static Boolean Getboolean (context context, String strkey) {sharedpreferences setpreferences = context.        Getsharedpreferences (Spfilename, context.mode_private);        Boolean result = Setpreferences.getboolean (strkey, false);    return result; public static Boolean Getboolean (context context, String strkey, Boolean Strdefau LT) {Sharedpreferences setpreferences = context.getsharedpreferences (Spfilename, Context.mode_priv        ATE);        Boolean result = Setpreferences.getboolean (strkey, Strdefault);    return result;        } public static void Putboolean (context context, String strkey, Boolean strdata) { SharedpreferencEs activitypreferences = context.getsharedpreferences (Spfilename, context.mode_private);        Sharedpreferences.editor Editor = Activitypreferences.edit ();        Editor.putboolean (strkey, strdata);    Editor.commit (); } public static int getInt (context context, String strkey) {sharedpreferences setpreferences = Context.getshare        Dpreferences (Spfilename, context.mode_private);        int result = Setpreferences.getint (strkey,-1);    return result; } public static int getInt (context context, String strkey, int strdefault) {Sharedpreferences setpreferences =        Context.getsharedpreferences (Spfilename, context.mode_private);        int result = Setpreferences.getint (strkey, Strdefault);    return result;  } public static void Putint (context context, String strkey, int strdata) {sharedpreferences activitypreferences = Context.getsharedpreferences (Spfilename, Context.mode_privaTE);        Sharedpreferences.editor Editor = Activitypreferences.edit ();        Editor.putint (strkey, strdata);    Editor.commit (); } public static long Getlong (context context, String strkey) {sharedpreferences setpreferences = Context.getsha        Redpreferences (Spfilename, context.mode_private);        Long result = Setpreferences.getlong (strkey,-1);    return result;  } public static long Getlong (context context, String strkey, long Strdefault) {sharedpreferences setpreferences        = Context.getsharedpreferences (Spfilename, context.mode_private);        Long result = Setpreferences.getlong (strkey, Strdefault);    return result; } public static void Putlong (context context, String strkey, long strdata) {sharedpreferences Activitypreferenc        Es = context.getsharedpreferences (spfilename, context.mode_private);        Sharedpreferences.editor Editor = Activitypreferences.edit (); Editor.putloNg (Strkey, strdata);    Editor.commit (); }}

Appconstants.java

Package com.zwb.splashdemo.utils;/** * Class Description: * ZWB * Time: 16-5-7 11:34 * Email: [Email protected] */public class Appconstants {
   public static final String First_open = "First_open";}

Layout resource File

Activity_guide.xml

<?xml version= "1.0" encoding= "Utf-8"? ><relativelayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Match_parent "android:layout_height=" match_parent "> <framelayout and Roid:layout_width= "Match_parent" android:layout_height= "match_parent" > <android.support.v4.view.viewp Ager android:id= "@+id/vp_guide" android:layout_width= "Match_parent" android:layout_height = "Match_parent"/> </FrameLayout> <button android:id= "@+id/btn_enter" Android:layout_ Width= "200DP" android:layout_height= "50DP" android:textsize= "20sp" android:textcolor= "@android: color/ White "android:background=" #B6292D "android:layout_margintop=" 410DP "android:layout_centerhorizontal= "True" android:visibility= "Gone"/> <linearlayout android:id= "@+id/ll" android:layout _width= "Wrap_content" Androidoid:layout_height= "Wrap_content" android:layout_alignparentbottom= "true" android:layout_centerhorizontal= "tr            UE "android:layout_marginbottom=" 24.0dip "android:orientation=" Horizontal "> <imageview Android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:layout_gravity= "Center_vertical" android:clickable= "true" android:padding= "10.0dip" android:src= "@drawab Le/dot_selector "/> <imageview android:layout_width=" Wrap_content "Android:layout_heigh t= "Wrap_content" android:layout_gravity= "center_vertical" android:clickable= "true" Androi d:padding= "10.0dip" android:src= "@drawable/dot_selector"/> <imageview android:layout_w            Idth= "Wrap_content" android:layout_height= "wrap_content" android:layout_gravity= "center_vertical" Android:clickabLe= "true" android:padding= "10.0dip" android:src= "@drawable/dot_selector"/> <im Ageview android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android: Layout_gravity= "Center_vertical" android:clickable= "true" android:padding= "10.0dip" Andro id:src= "@drawable/dot_selector"/> </LinearLayout></RelativeLayout>

Guid_view1.xml A total of four layouts are the same
<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "    android:layout_width=" match_parent "    android:layout_height=" match_parent "    android:o rientation= "vertical" >    <imageview        android:layout_width= "match_parent"        android:layout_height= "Match_parent"        android:scaletype= "Centercrop"        android:src= "@mipmap/img01"         /></linearlayout >

Activity_splash.xml

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "    android:orientation=" vertical "android:layout_width=" match_parent "    android:layout_height=" Match_parent ">    <imageview        android:id=" @+id/iv_splash "        android:layout_width=" Match_parent "        android:layout_height= "match_parent"        android:adjustviewbounds= "true"        android:contentdescription= " @null "        android:scaletype=" Centercrop "        android:src=" @mipmap/splash "/></linearlayout>
Animation resource File

Dot_focused.xml

<?xml version= "1.0" encoding= "Utf-8"? ><shape xmlns:android= "Http://schemas.android.com/apk/res/android"    android:shape= "Oval" >    <solid android:color= "#aaFFFFFF"/>    <corners android:radius= " 5dip "/></shape>

Dot_normal.xml

<?xml version= "1.0" encoding= "Utf-8"? ><shape xmlns:android= "Http://schemas.android.com/apk/res/android"    android:shape= "Oval" >    <solid android:color= "#33000000"/>    <corners android:radius= "5dip" /></shape>

Dot_selector.xml

<?xml version= "1.0" encoding= "UTF-8"? ><selector  xmlns:android= "http://schemas.android.com/apk/res/ Android ">    <item android:state_enabled=" true "android:drawable=" @drawable/point2 "/>    <item Android:state_enabled= "false" android:drawable= "@drawable/point1"/></selector>

Button_shape.xml

<?xml version= "1.0" encoding= "Utf-8"? ><shape xmlns:android= "Http://schemas.android.com/apk/res/android" >    <!--     <solid android:color= "#ce102c"/>-        <stroke android:width= "0.5DP"         Android:color= "#ce102c"/>    <corners android:radius= "200DP"/>        <solid        android:color= "@ Android:color/transparent "         />    <padding        android:bottom=" 5DP "        android:left=" 5DP        " android:right= "5DP"        android:top= "5DP"/></shape>
Splash page to start
Splashactivity.java

Package Com.zwb.splashdemo.activity;import Android.app.activity;import Android.content.intent;import Android.os.bundle;import Android.os.handler;import Com.zwb.splashdemo.mainactivity;import Com.zwb.splashdemo.R; Import com.zwb.splashdemo.utils.appconstants;import com.zwb.splashdemo.utils.sputils;/** * Splash */public class launched Splashactivity extends activity{@Override protected void onCreate (Bundle savedinstancestate) {super.oncreat        E (savedinstancestate);        Determine whether to start the application for the first time Boolean isfirstopen = Sputils.getboolean (this, appconstants.first_open);            If this is the first boot, first enter the function boot page if (!isfirstopen) {startactivity (new Intent (this, welcomeguideactivity.class));            Finish ();        Return        }//If it is not the first time to start Setcontentview (R.layout.activity_splash); New Handler (). postdelayed (New Runnable () {@Override public void run () {Enterhomeact            Ivity ();    }}, 1500); } Private void Enterhomeactivity () {startactivity (new Intent (this, mainactivity.class));    Finish (); }}

Activity of the Guide page

Welcomeguideactivity.java

Package Com.zwb.splashdemo.activity;import Android.app.activity;import Android.content.intent;import Android.os.bundle;import Android.support.v4.view.viewpager;import Android.view.layoutinflater;import Android.view.view;import Android.widget.button;import Android.widget.imageview;import Android.widget.LinearLayout ; Import Com.zwb.splashdemo.r;import Com.zwb.splashdemo.adapter.guideviewpageradapter;import Com.zwb.splashdemo.utils.appconstants;import Com.zwb.splashdemo.utils.sputils;import Java.util.ArrayList;import    java.util.list;/** * Guide page Activity */public Class Welcomeguideactivity extends activity implements View.onclicklistener {    Private Viewpager VP;    Private Guideviewpageradapter adapter;    Private list<view> views;    Private Button startbtn; Boot image resource private static final int[] Pics = {r.layout.guid_view1, r.layout.guid_view2, R.LAYOUT.GUID_VIEW3, R    . LAYOUT.GUID_VIEW4};    The bottom dot picture private imageview[] dots; Record the currently selected location private int currentindex;        @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);        Setcontentview (R.layout.activity_guide);        views = new arraylist<> (); 4769.71//Initialize the Boot Page view list for (int i = 0; i < pics.length; i++) {View view = Layoutinflater.from            (this). Inflate (pics[i], NULL);                if (i = = pics.length-1) {startbtn = (Button) View.findviewbyid (R.id.btn_login);                Startbtn.settag ("enter");            Startbtn.setonclicklistener (this);        } views.add (view);        } VP = ((Viewpager) Findviewbyid (r.id.vp_guide));        Initialize Adapter adapter = new Guideviewpageradapter (views);        Vp.setadapter (adapter);        Vp.setonpagechangelistener (New Pagechangelistener ());    Initdots ();    } @Override protected void Onresume () {super.onresume ();      } @Override protected void OnPause () {super.onpause ();  If you switch to the background, set the next time you do not enter the function boot page sputils.putboolean (welcomeguideactivity.this, Appconstants.first_open, true);    Finish ();    } @Override protected void OnStop () {super.onstop ();    } @Override protected void OnDestroy () {Super.ondestroy ();        } private void Initdots () {LinearLayout LL = (linearlayout) Findviewbyid (R.ID.LL);        Dots = new Imageview[pics.length];  Loop gets the dot picture for (int i = 0; i < pics.length; i++) {//Get a linearlayout below each sub-element dots[i] =            (ImageView) Ll.getchildat (i);            Dots[i].setenabled (false);//Both are set to gray dots[i].setonclicklistener (this);        Dots[i].settag (i);//Set position tag, easy to remove with the current position corresponding} Currentindex = 0; Dots[currentindex].setenabled (TRUE);        Set to white, check status}/** * Set Current View * * @param position */private void Setcurview (int position) {       if (Position < 0 | | position >= pics.length) {return; } vp.setcurrentitem (position); }/** * Sets the current cue point * * @param position */private void Setcurdot (int position) {if (position &L T 0 | | Position > Pics.length | |        Currentindex = = position) {return;        } dots[position].setenabled (True);        Dots[currentindex].setenabled (FALSE);    Currentindex = position;            @Override public void OnClick (View v) {if (V.gettag (). Equals ("enter")) {entermainactivity ();        Return        } int position = (Integer) v.gettag ();        Setcurview (position);    Setcurdot (position); } private void Entermainactivity () {Intent Intent = new Intent (Welcomeguideactivity.this, Splash        Activity.class);        StartActivity (Intent);        Sputils.putboolean (Welcomeguideactivity.this, Appconstants.first_open, true);    Finish (); } Private class Pagechangelistener implements Viewpager.onpagechangelistener {//when sliding@Override public void onpagescrollstatechanged (int position) {//arg0 ==1 is sliding when the state changes, arg0==        2 of the time the implied slide is finished, arg0==0 when the hour of the silent do not do anything.            }//The current page is being slid when called @Override public void onpagescrolled (int position, float arg1, int arg2) {        ARG0: Current page, and the page you clicked to swipe//arg1: Percent of current page offset//arg2: Pixel position of current page offset}//Call when new page is selected        @Override public void onpageselected (int position) {//sets the bottom of the small point check State setcurdot (position); }    }}

Adapter of the Boot page

Guideviewpageradapter.java

Package Com.zwb.splashdemo.adapter;import Android.support.v4.view.pageradapter;import Android.support.v4.view.viewpager;import Android.view.view;import Android.view.viewgroup;import java.util.List;/*    * * Guide page Adpter */public class Guideviewpageradapter extends Pageradapter {private list<view> views;        Public Guideviewpageradapter (list<view> views) {super ();    This.views = views;        } @Override public int getcount () {if (views! = null) {return views.size ();    } return 0; } @Override public void Destroyitem (ViewGroup container, int position, object object) {(Viewpager) containe    R). Removeview (Views.get (position));    } @Override Public Boolean isviewfromobject (view view, Object object) {return view = = ((view) object); } @Override Public Object instantiateitem (viewgroup container, int position) {((Viewpager) container). Addvie        W (views.get (position), 0); Return Views.get (POSition); }}

You are finished, attached to the demo .....

http://download.csdn.net/detail/zuo_0625/9512895

Demo inside the picture resources are more, the file is a bit large.

Android Boot page Splash design

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.