XML file
<relativelayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Xmlns:tools= "Http://schemas.android.com/tools"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:paddingleft= "@dimen/activity_horizontal_margin"
android:paddingright= "@dimen/activity_horizontal_margin"
android:paddingtop= "@dimen/activity_vertical_margin"
android:paddingbottom= "@dimen/activity_vertical_margin"
Tools:context= ". Mainactivity ">
<textview
Android:textsize= "10DP"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:text= "To prevent user information from being compromised, please log in using the local number"
Android:id= "@+id/textview"
Android:layout_alignparenttop= "true"
Android:layout_centerhorizontal= "true"/>
<edittext
Android:gravity= "Left|center"
Android:textsize= "15DP"
Android:hint= "Please enter your phone number"
Android:layout_width= "Fill_parent"
android:layout_height= "50DP"
Android:inputtype= "Phone"
android:ems= "11"
Android:id= "@+id/edittext"
android:layout_below= "@+id/textview"
android:layout_margintop= "60DP"
Android:layout_alignparentright= "true"
Android:layout_alignparentend= "true"
android:layout_torightof= "@+id/imageview"
android:layout_toendof= "@+id/imageview"/>
<imageview
Android:scaletype= "Fitcenter"
Android:adjustviewbounds= "false"
Android:layout_width= "30DP"
android:layout_height= "30DP"
Android:id= "@+id/imageview"
android:src= "@drawable/password"
Android:layout_alignparentleft= "true"
Android:layout_alignparentstart= "true"
android:layout_alignbottom= "@+id/edittext"/>
<edittext
Android:gravity= "Left|center"
Android:textsize= "15DP"
Android:adjustviewbounds= "false"
Android:hint= "Please enter the verification code"
Android:layout_width= "200DP"
android:layout_height= "50DP"
Android:inputtype= "Phone"
android:ems= "6"
Android:id= "@+id/edittext2"
android:layout_below= "@+id/imageview"
android:layout_alignleft= "@+id/edittext"
Android:layout_alignstart= "@+id/edittext"
android:layout_toleftof= "@+id/button1"
android:layout_tostartof= "@+id/button1"/>
<imageview
Android:scaletype= "Fitcenter"
Android:layout_width= "30DP"
android:layout_height= "30DP"
Android:id= "@+id/imageview2"
android:src= "@drawable/zhanghao"
Android:layout_alignbottom= "@+id/edittext2"
Android:layout_alignparentleft= "true"
Android:layout_alignparentstart= "true"/>
<button
Android:textsize= "15DP"
Android:background= "#ffffff"
Android:textcolor= "#ff00"
Android:layout_width= "150DP"
android:layout_height= "30DP"
Android:text= "Get Verification Code"
Android:id= "@+id/button1"
android:layout_aligntop= "@+id/edittext2"
android:layout_alignright= "@+id/edittext"
Android:layout_alignend= "@+id/edittext"
android:layout_alignbottom= "@+id/edittext2"/>
<button
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
android:text= "Login"
Android:id= "@+id/button2"
Android:textsize= "25DP"
Android:layout_centervertical= "true"
Android:layout_centerhorizontal= "true"/>
<checkbox
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:id= "@+id/checkbox"
android:layout_below= "@+id/button2"
Android:layout_alignparentleft= "true"
Android:layout_alignparentstart= "true"
Android:text= "Agree and accept * * * *"/>
<textview
android:gravity= "Center"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:layout_torightof= "@+id/checkbox"
android:text= "Terms of service"
Android:textcolor= "#00f"
android:layout_below= "@+id/button2"
android:layout_alignbottom= "@+id/checkbox"/>
</RelativeLayout>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/2E/wKiom1V1jpPC0CiaAAEMQpUtJaM307.jpg "title=" Dame1.png "alt=" Wkiom1v1jppc0ciaaaemqputjam307.jpg "/>
Import Android.os.CountDownTimer;
Import android.support.v7.app.ActionBarActivity;
Import Android.os.Bundle;
Import Android.view.Menu;
Import Android.view.MenuItem;
Import Android.view.View;
Import Android.widget.Button;
public class Mainactivity extends Actionbaractivity {
Private Timecount time;
private Button checking;
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
Time = new Timecount (30000, 1000);//Construct Countdowntimer Object
checking = (Button) Findviewbyid (R.id.button1);
Checking.setonclicklistener (New View.onclicklistener () {
@Override
public void OnClick (View v) {
Time.start ();//Start timing
}
});
}
Class Timecount extends Countdowntimer {
Public Timecount (Long millisinfuture, long Countdowninterval) {
Super (Millisinfuture, countdowninterval);//parameter is the total length of time, and timing interval
}
@Override
public void OnFinish () {//trigger on completion of the timer
Checking.settext ("Re-verification");
Checking.setclickable (TRUE);
}
@Override
public void OnTick (long millisuntilfinished) {//timekeeping process display
Checking.setclickable (FALSE);
Checking.settext (millisuntilfinished/1000+ "re-acquired after");
}
}
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/2F/wKiom1V1k2Dhdl2cAAE8pGFr7uM116.jpg "title=" Damo2.png "alt=" Wkiom1v1k2dhdl2caae8pgfr7um116.jpg "/>
This article is from the "Android 0 to 1 Process" blog, be sure to keep this source http://nomeatnofat.blog.51cto.com/10289035/1659842
Relativelayout login screen and get verification code after click to Countdown button