Android Launch page guide page login Registration Homepage Universal Framework

Source: Internet
Author: User

This is not because this is difficult to write, but to find out that every time a new write a project to write these things, it is better to take them out, you can save a lot of time later.

1: Start the page an animation and then go to the app

2: First Open boot page

3: Landing interface (Of course, this UI will have different needs, but change it to do it)

4: Registration Interface (same login interface)

5: Main interface

6: Some general-purpose controls (put a dialog here, drop-down refresh pull-up loading control)

Basic on these content, every time write or copy once, also quite a waste of time, the following step by step put up, also hope to some just work comrades some help




Here simply put a color gradient animation, placed in what special needs to change it, involving the knowledge point is also a gradient animation

public class Splashactivity extends Baseactivity {private Animation myanimation_alpha;private relativelayout rl_ Homepage; @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_splash); rl_homepage = (relativelayout) Findviewbyid (R.id.rl_homepage);    Initializes an instance object according to its own constructor myanimation_alpha=new Alphaanimation (0.3f, 1.0f); Rl_homepage.setanimation (Myanimation_alpha ); Myanimation_alpha.setduration (+); Myanimation_alpha.setanimationlistener (new Animationlistener () {@ overridepublic void Onanimationstart (Animation Animation) {} @Overridepublic void Onanimationrepeat (Animation Animation) {} @Overridepublic void Onanimationend (animation animation) {Intent Intent = new Intent (Getapplication (), Guideactivity.class);            Startactivitywithanim (intent);            Finish ();}}); Myanimation_alpha.startnow ();         }}

This piece of content is simple, that's all, note that there's a way
Startactivitywithanim

This is put in my baseactivity inside, we usually encapsulate some common methods in the inside, such as switch page animation and so on, I put a left to exit the right into the animation, of course, in the use of baseactivity activity inside, need to animate the page, To use these two animated methods

public class Baseactivity extends fragmentactivity  {TextView tv_title; @Overrideprotected void OnCreate (Bundle Savedinstancestate) {super.oncreate (savedinstancestate); tv_title = (TextView) Findviewbyid (r.id.tv_title);} If there is a header directly bound Back button click event public         void backpressed (view view) {        finishwithanim ();    }       protected void Settitle (String title) {if (tv_title!=null) {Tv_title.settext (title);}    } /*** * LED painting start  activity * @param intent */protected void Startactivitywithanim (Intent intent) {        startactivity ( Intent);         Overridependingtransition (r.anim.default_fromright_in,r.anim.default_toleft_out);} /*** * Draw exit  activity */protected void Finishwithanim () {finish (); Overridependingtransition (r.anim.default_ fromright_in,r.anim.default_toleft_out);}}
There are 4 anim files, which are given below.

Default_fromleft_in.xml

<?xml version= "1.0" encoding= "Utf-8"?> <set  xmlns:android= "http://schemas.android.com/apk/res/ Android "      android:shareinterpolator=" false ">      <translate          android:duration=" + "          android: Fillafter= "true"          android:fromxdelta= " -100%p"          android:fromydelta= "0"          android:toxdelta= "0"          Android:toydelta= "0"/>  </set>  

Default_fromright_in.xml

<?xml version= "1.0" encoding= "Utf-8"?> <set  xmlns:android= "http://schemas.android.com/apk/res/ Android "      android:shareinterpolator=" false ">      <translate          android:duration="          Android:fillafter= "true"          android:fromxdelta= "100%p"          android:fromydelta= "0"          android:toxdelta= "0"          android:toydelta= "0"/>  </set>  


Default_toleft_out.xml

<?xml version= "1.0" encoding= "Utf-8"?> <set  xmlns:android= "http://schemas.android.com/apk/res/ Android "      android:shareinterpolator=" false ">        <translate          android:duration=" + "          android: Fillafter= "true"          android:fromxdelta= "0"          android:fromydelta= "0"          android:toxdelta= " -100%p"          Android:toydelta= "0"/>    </set>  

Default_toright_out.xml

<?xml version= "1.0" encoding= "Utf-8"?> <set  xmlns:android= "http://schemas.android.com/apk/res/ Android "      android:shareinterpolator=" false ">        <translate          android:duration=" + "          android: Fillafter= "true"          android:fromxdelta= "0"          android:fromydelta= "0"          android:toxdelta= "100%p"          Android:toydelta= "0"/>    </set>  

The first start screen is finished, then go to the boot page



The main guide page is viewpager switch page, to the last page when a button to enter the application, some need to have the following four small dot requirements look may not be the same, you change it.

public class Guideactivity extends Baseactivity implements Onpagechangelistener {/** * viewpager */private viewpager ViewP Ager;private imageview[] tips;private imageview[] mimageviews;private int[] imgidarray;private Button bt_enter;@ overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview ( R.layout.activity_guide); ViewGroup Group = (viewgroup) Findviewbyid (r.id.viewgroup); bt_enter = (Button) Findviewbyid (r.id.bt_enter); ViewPager = (Viewpager) Findviewbyid (R.id.viewpager); Bt_enter.setonclicklistener (new Onclicklistener () {@Overridepublic void OnClick (View v) {Intent Intent = new Intent (guideactivity.this,loginactivity.class); Startactivitywithanim (Intent); Finish ();}}); Imgidarray = new int[] {r.drawable.p1, r.drawable.p2, r.drawable.p3,r.drawable.p4};tips = new Imageview[imgidarray.leng th];for (int i = 0; i < tips.length; i++) {ImageView ImageView = new ImageView (this); Imageview.setlayoutparams (New Layo Utparams (Ten)); Tips[i] = iMageview;if (i = = 0) {tips[i].setbackgroundresource (r.drawable.page_indicator_focused);} else {tips[i]. Setbackgroundresource (r.drawable.page_indicator_unfocused);} Linearlayout.layoutparams layoutparams = new Linearlayout.layoutparams (New Viewgroup.layoutparams (LayoutParams.WRAP _content,layoutparams.wrap_content)); layoutparams.leftmargin = 15;layoutparams.rightmargin = 15; Layoutparams.bottommargin = 20;group.addview (ImageView, layoutparams);} Mimageviews = new Imageview[imgidarray.length];for (int i = 0; i < mimageviews.length; i++) {ImageView ImageView = new ImageView (this); Mimageviews[i] = Imageview;imageview.setbackgroundresource (Imgidarray[i]);} Viewpager.setadapter (New Myadapter ()); Viewpager.setonpagechangelistener (this); Viewpager.setcurrentitem (0);} /** * * @author xiaanming * */public class Myadapter extends Pageradapter {@Overridepublic int getcount () {return Imgida Rray.length;} @Overridepublic boolean isviewfromobject (View arg0, Object arg1) {return arg0 = = arg1;} @OverridepublIC void Destroyitem (View container, int position, object object) {(Viewpager) container). Removeview (mimageviews[ position% mimageviews.length]);} @Overridepublic Object Instantiateitem (View container, int position) {((Viewpager) container). AddView (mimageviews[ position% Mimageviews.length], 0); return mimageviews[position% mimageviews.length];}} @Overridepublic void onpagescrollstatechanged (int arg0) {} @Overridepublic void onpagescrolled (int arg0, float arg1, int a RG2) {} @Overridepublic void onpageselected (int arg0) {setimagebackground (arg0% mimageviews.length), if (arg0 = = ( mimageviews.length-1)) {bt_enter.setvisibility (view.visible);} Else{bt_enter.setvisibility (View.gone);}} /** * * @param selectitems */private void setimagebackground (int selectitems) {for (int i = 0; i < tips.length; i++) { if (i = = Selectitems) {tips[i].setbackgroundresource (r.drawable.page_indicator_focused);} else {tips[i]. Setbackgroundresource (r.drawable.page_indicator_unfocused);}}} @Overridepublic void onbackpressEd () {Finishwithanim (); super.onbackpressed ();}} 

The layout file is also very simple

<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" android:layout_width= "Fill_parent" android:layout_height= "fill_parent" android:orientation= "vertical" > &LT;ANDROID.SUPPORT.V4.VIEW.VIEWP Ager android:id= "@+id/viewpager" android:layout_width= "Fill_parent" android:layout_height = "Wrap_content"/> <relativelayout android:layout_width= "Fill_parent" Android:                layout_height= "wrap_content" android:orientation= "vertical" > <linearlayout Android:id= "@+id/viewgroup" android:layout_width= "fill_parent" android:layout_height= "Wrap_c                Ontent "android:layout_alignparentbottom=" true "android:layout_marginbottom=" 30DP " Android:gravity= "Center_horizontal" android:orientation= "Horizontal" > </linearlayout > </relativelayout> <button android:id= "@+id/bt_enter" android:layout_width= "Match_parent" Andro id:layout_height= "50DP" android:layout_alignparentbottom= "true" android:layout_marginbottom= "20DP" an droid:layout_marginleft= "20DP" android:layout_marginright= "20DP" android:visibility= "Gone" android:te   Xt= "Go to Application"/> </RelativeLayout>

And then it's login registration screen.

Login interface Registration Interface These two variables will be relatively large, this is probably put on the general will focus on the

There is a consent clause at the time of registration, this is a more general



This detailed code is not affixed, the meaning is not big, the project will be sent up in the back, here alone the agreement of the code to paste a

        <linearlayout            android:layout_width= "match_parent"            android:layout_height= "Wrap_content"             android: gravity= "center"            android:padding= "5DP" >            <checkbox                android:id= "@+id/checkbox1"                android: Layout_width= "Wrap_content"                android:layout_height= "wrap_content"                android:layout_alignparentleft= "true"                android:layout_alignparenttop= "true"                android:button= "@drawable/checkbox_selector"                android:text = "I have read and agree"/>            <textview                android:layout_width= "wrap_content"                android:layout_height= "Wrap_ Content "                android:text=" terms of use and Privacy policy "                android:textcolor=" @color/themecolor "/>        </linearlayout >
Checkbox_selector
<?xml version= "1.0" encoding= "Utf-8"? ><selector    xmlns:android= "http://schemas.android.com/apk/res/ Android ">      <item android:state_checked=" true "android:drawable=" @drawable/ic_item_unselect "/>      <item android:state_selected= "true" android:drawable= "@drawable/ic_item_unselect" ></item>      < Item android:state_pressed= "True" android:drawable= "@drawable/ic_item_unselect" ></item>      <item Android:state_checked= "false" android:drawable= "@drawable/ic_item_select"/>  </selector>  

Okay, this is the end of this thing.

Then there's the main interface.

The main interface is now put a tabhost and fragment the bottom of the navigation bar, of course, you want to what effect can be written on their own, there is no need to put all the inside, it is obviously impossible




Pull down, pull down, and the ListView won't write.




Then a slightly nicer dialog is essential



Code will not be affixed, special is too troublesome, the project itself download OH

Click to download


Android Launch page guide page login Registration Homepage Universal Framework

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.