代码工程下载链接
开发环境:Android Studio
模拟运行:Android Emulator – Nexus_5X_API_24
requestWindowFeature(Window.FEATURE_NO_TITLE);// 隐藏标题栏
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);//隐藏运营图标、点量等
super.onCreate(savedInstanceState);
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFAE4"
android:orientation="vertical"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="81dp"
android:src="@mipmap/test3"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="90dp"
android:src="@mipmap/ic_launcher"/>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="账号:"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/user"/>
TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="300px"
android:text="密码:"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/password"
android:inputType="textPassword"/>
TableRow>
TableLayout>
LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="登录"
android:onClick="login"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="记住密码"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="自动登录"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="接收推广"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:text="忘记密码"
android:onClick="forgetpassword"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="注册账号"
android:onClick="register"/>
FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="63dp"
android:orientation="vertical" >
<TextView
android:id="@+id/loading"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ProgressBar
style="?android:attr/progressBarStyleSmall"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginBottom="10dp" />
LinearLayout>
public void login(View view){
if( true ){
StringBuilder sb = new StringBuilder();
sb.append("登录成功!"+"\n");
sb.append("用户名:" + userName.getText().toString()+"\n");
sb.append("密码:" + password.getText().toString()+"\n");
Toast.makeText(this, sb.toString(), Toast.LENGTH_LONG).show();
Intent intent = new Intent(); //登录到ResultActivity页面
intent.setClass(this, ResultActivity.class);
intent.putExtra("info", sb.toString());
this.startActivity(intent);
}
}
//打开忘记密码界面
public void forgetpassword(View view){
StringBuilder sb = new StringBuilder();
Intent intent = new Intent();
intent.setClass(this, ForgetPassActivity.class);
intent.putExtra("info", sb.toString());
this.startActivity(intent);
}
//打开注册界面
public void register(View view){
StringBuilder sb = new StringBuilder();
Intent intent = new Intent();
intent.setClass(this, RegisterActivity.class);
intent.putExtra("info", sb.toString());
this.startActivity(intent);
}