Android Imitation Sina microblogging launch interface or landing interface (1) _android

Source: Internet
Author: User

This article for everyone to share the Android imitation Sina Weibo launch interface & Landing interface of the specific implementation code for your reference, the specific content as follows

Start interface

There are two main functions:

1. Load Start animation
2. Judge the network, some people directly into the landing interface, otherwise to set up the network

Code is simpler, mainly using the Alphaanimation () method and animation listener, so that a picture to produce a gradient animation. When the animation starts to judge the network, the end of the animation to complete the judgment and enter the landing interface.

/** * Created by D&ll on 2016/5/25. * Initial Page Loading interface * * * public class Splashactivity extends activity {@Override protected void onCreate (Bundle savedinstancesta
 TE) {super.oncreate (savedinstancestate);
 Setcontentview (R.layout.splash);
 ImageView splashimage = (imageview) Findviewbyid (r.id.splashimage);
 Transparency Gradient animation Alphaanimation animation = new Alphaanimation (0.1f, 1.0f);
 Set animation length animation.setduration (3000);
 Associating components and animations splashimage.setanimation (animation); Animation.setanimationlistener (New Animation.animationlistener () {//Animation startup execution @Override public void Onanimationstart (A
  Nimation animation) {Toast.maketext (Splashactivity.this, "Welcome to Demon to make Weibo", Toast.length_long). Show ();
  Check and network method Tools.checknetwork (Splashactivity.this); }//Animation end execution @Override public void Onanimationend (Animation Animation) {Intent Intent = new Intent (splashactivity.
  this, loginactivity.class);
  StartActivity (Intent);
  Finish (); }//Animation repeat execution @Override public void OnanimationrEpeat (Animation Animation) {}});

 }

The

uses Connectivitymanager to obtain the connection service for the system, and then gets the Networkinfo object that represents the networked state, gets the connection to the network, and generates a Alertdialog boot for network settings if there is no network. The method is located in Tools.java.

 /** * Settings Network * * @param context/public static void Checknetwork (final splashactivity context) {if (!)
  NetworkStatus (context)) {TextView msg = new TextView (context); Msg.settext ("Please set up the network!")
  ");
   Alertdialog.builder B = new Alertdialog.builder (context). SetIcon (r.drawable.notnet). Settitle ("No Available Network"). Setmessage ("Do you want to set up your network?").
  "); B.setpositivebutton ("Yes", new Dialoginterface.onclicklistener () {public void OnClick (dialoginterface dialog, int Whichb
  Utton) {//jump to set the network interface context.startactivity (new Intent (settings.action_settings)); }). Setneutralbutton ("No", new Dialoginterface.onclicklistener () {public void OnClick (dialoginterface dialog, int whi
   Chbutton) {dialog.cancel ();
  Context.finish ();
 ). Create (). Show ();  }/** * Judge network Status/public static Boolean NetworkStatus (context context) {//Get System Connection service Connectivitymanager Connect = (Connectivitymanager) context.getsystemservice (context.
 Connectivity_service); if (connect = null) {return FAlse;
  else {//Get the Networkinfo object that represents the networking state, get the network connection networkinfo[] Infos = Connect.getallnetworkinfo ();
   if (infos!= null) {for (Networkinfo Network:infos) {if (network.getstate () = = NetworkInfo.State.CONNECTED) {
   return true;
 }}} return false;


 }

Splashactivity Layout File Splash.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 ">

 < ImageView
 android:id= "@+id/splashimage"
 android:layout_width= "match_parent"
 android:layout_height= "Match_parent"
 android:scaletype= "Fitxy"
 android:src= "@drawable/splashimage"/>

 <progressbar
 style= "@android: Style/widget.progressbar.inverse"
 android:layout_width= "Wrap_content"
 android: layout_height= "Wrap_content"
 android:layout_alignparentbottom= "true"
 Android:layout_alignparentstart = "true"
 android:layout_gravity= "center"
 android:layout_marginbottom= "64DP"
 android:layout_ marginstart= "130DP" >
 </ProgressBar>
</RelativeLayout>


Landing interface

This interface has only a few buttons, so it fits in a blog.

The Twitter button triggers access to the licensing interface

public class Loginactivity extends activity {
 private Button sinalogin;

 @Override
 protected void onCreate (Bundle savedinstancestate) {
 super.oncreate (savedinstancestate);
 Setcontentview (r.layout.login);

 Sinalogin = (Button) Findviewbyid (r.id.sinalogin);
 Sinalogin.setonclicklistener (New View.onclicklistener () {
  @Override public
  void OnClick (View v) {
  Intent Intent = new Intent (loginactivity.this, oauthactivity.class);
  StartActivity (intent);
  LoginActivity.this.finish ();}}
 );
 }




The layout file Login.xml two custom style edittext, a normal button (here is purely furnished). Only the microblogging login button is useful.

<?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:background=" @drawable Background "android:gravity=" center_vertical "android:orientation=" vertical "android:paddingbottom=" @dimen Activity_vertical_margin "android:paddingleft=" @dimen/activity_horizontal_margin "android:paddingright=" @dimen Activity_horizontal_margin "android:paddingtop=" @dimen/activity_vertical_margin "> <edittext android:id=" @+ Id/username "android:layout_width=" match_parent "android:layout_height=" 40dip "android:background=" @drawable/bg_ EditText "android:ems=" "android:inputtype=" Textpersonname "> </EditText> <edittext android:id=" @+id/p
 Assworld "android:layout_width=" match_parent "android:layout_height=" 40dip "android:layout_margintop=" 20dip " android:background= "@drawable/bg_edittext" android:ems= "ten" Android:inpuTtype= "Textpassword"/> <linearlayout android:layout_width= "Fill_parent" android:layout_height= "android:orientation=" Horizontal "> <button android:id=" @+id/login "android:layout_width=" 200DP "Android:la yout_height= "Wrap_content" android:layout_margintop= "20dip" android:layout_weight= "1" android:text= "Login"/> <B Utton android:id= "@+id/sinalogin" android:layout_width= "200DP" android:layout_height= "38DP" Android:layout_margint op= "20dip" android:layout_weight= "1" android:background= "@drawable/weibologin"/> </LinearLayout> </
 Linearlayout>

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

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.