mProgressView=newProgressBar(this);
mProgressView.setLayoutParams(newLinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
mProgressView.setBackgroundColor(Color.WHITE);
mProgressView.setBottom(8);
mProgressView.setVisibility(View.GONE);
mLoginFormView=newScrollView(this);
mLoginFormView.setLayoutParams(newLinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT));
//根布局参数
LinearLayout.LayoutParams layoutParamsRoot =newLinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParamsRoot.gravity= Gravity.CENTER;
//根布局
LinearLayout layoutRoot =newLinearLayout(this);
layoutRoot.setLayoutParams(layoutParamsRoot);
layoutRoot.setOrientation(LinearLayout.VERTICAL);
layoutRoot.addView(mProgressView);
//title布局
LinearLayout.LayoutParams layoutParamsTitle =newLinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParamsTitle.gravity=Gravity.CENTER_HORIZONTAL;
//title
AppCompatTextView title =newAppCompatTextView(this);
title.setText("登录");
title.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
title.setTextSize(30);
layoutRoot.addView(title,layoutParamsTitle);
//用户名text布局
LinearLayout.LayoutParams layoutParamsEmil =newLinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParamsEmil.gravity=Gravity.CENTER_HORIZONTAL;
//用户名text
mEmailView=newAutoCompleteTextView(this);
mEmailView.setHint("Email");
mEmailView.setInputType(0);
mEmailView.setMaxLines(1);
//用户名布局
TextInputLayout inputLayoutEmil =newTextInputLayout(this);
inputLayoutEmil.addView(mEmailView,layoutParamsEmil);
layoutRoot.addView(inputLayoutEmil,newLinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
//密码Text布局
LinearLayout.LayoutParams layourParamsPassword =newLinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
layourParamsPassword.gravity=Gravity.CENTER_HORIZONTAL;
//密码Text
mPasswordView=newEditText(this);
mPasswordView.setHint("Password");
mPasswordView.setImeActionLabel("Sign in",0);
mPasswordView.setImeOptions(0);
mPasswordView.setInputType(InputType.TYPE_CLASS_TEXT| InputType.TYPE_TEXT_VARIATION_PASSWORD);
mPasswordView.setMaxLines(1);
//密码布局
TextInputLayout inputLayoutPassword =newTextInputLayout(this);
inputLayoutPassword.addView(mPasswordView,layourParamsPassword);
layoutRoot.addView(inputLayoutPassword,newLinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
//登录Button布局
LinearLayout.LayoutParams layoutParamsLoginButton =newLinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParamsLoginButton.topMargin=16;
layoutParamsLoginButton.gravity=Gravity.CENTER_HORIZONTAL;
//登录Button
Button buttonLogin =newButton(this);
buttonLogin.setText("登录");
buttonLogin.setOnClickListener(newOnClickListener() {
@Override
public voidonClick(View view) {
attemptLogin();
}
});
layoutRoot.addView(buttonLogin,layoutParamsLoginButton);
//注册Button布局
LinearLayout.LayoutParams layoutParamsRegistButton =newLinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParamsLoginButton.topMargin=16;
layoutParamsRegistButton.gravity=Gravity.CENTER_HORIZONTAL;
//注册Button
Button buttonRegist =newButton(this);
buttonRegist.setText("注册");
buttonRegist.setOnClickListener(newOnClickListener() {
@Override
public voidonClick(View view) {
jumpRegist();
}
});
layoutRoot.addView(buttonRegist,layoutParamsRegistButton);
mLoginFormView.addView(layoutRoot);
setContentView(mLoginFormView);