Android 客户端登录界面实现
2013-09-03 19:25
585 查看
本文简单实现常用客户登录界面,如qq,微薄等客户端登录。
短暂停留界面:
登录界面:
实现比较简单,首先是短暂停留界面布局:
短暂停留界面:
登录界面:
实现比较简单,首先是短暂停留界面布局:
<?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:orientation="vertical" > <ImageView android:layout_width ="fill_parent" android:layout_height ="fill_parent" android:scaleType ="fitXY" android:src ="@drawable/splash" /> </LinearLayout>该界面对应的Activity:
/** * 应用启动短暂停留界面 * @author builder * */ public class SplashActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.splash); new Handler().postDelayed(new Runnable() { public void run() { Intent intent=new Intent(SplashActivity.this,LoginActivity.class); startActivity(intent); SplashActivity.this.finish();//结束本Activity } }, 1000);//设置执行时间 } }登录界面布局:
<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"> <ImageView android:id ="@+id/loginbutton" android:layout_width ="wrap_content" android:layout_height ="wrap_content" android:layout_centerHorizontal ="true" android:layout_marginTop ="50dp"/> <LinearLayout android:id ="@+id/input" android:layout_width ="fill_parent" android:layout_height ="wrap_content" android:layout_below ="@id/loginbutton" android:layout_marginLeft ="28.0dip" android:layout_marginRight ="28.0dip" android:orientation ="vertical" > <LinearLayout android:layout_width ="fill_parent" android:layout_height ="44.0dip" android:gravity ="center_vertical" android:orientation ="horizontal" > <EditText android:id ="@+id/searchEditText" android:layout_width ="0dp" android:layout_height ="fill_parent" android:layout_weight ="1" android:background ="@null" android:ems ="10" android:hint="输入帐号" android:imeOptions ="actionDone" android:singleLine ="true" android:textSize ="16sp" > <requestFocus /> </EditText> <Button android:id ="@+id/button_clear" android:layout_width ="20dip" android:layout_height ="20dip" android:layout_marginRight ="8dip" android:visibility ="visible" /> </LinearLayout> <View android:layout_width ="fill_parent" android:layout_height ="1.0px" android:layout_marginLeft ="1.0px" android:layout_marginRight ="1.0px" android:background ="#ffc0c3c4" /> <EditText android:id ="@+id/password" android:layout_width ="fill_parent" android:layout_height ="44.0dip" android:gravity ="center_vertical" android:background ="#00ffffff" android:inputType ="textPassword" android:hint="输入密码" android:maxLength ="16" android:maxLines ="1" android:textColorHint ="#ff666666" android:textSize ="16.0sp" /> </LinearLayout > <Button android:id ="@+id/buton1" android:layout_width ="270dp" android:paddingTop ="5.0dip" android:layout_height ="50dp" android:layout_marginLeft ="28.0dip" android:layout_marginRight ="28.0dip" android:layout_marginTop ="12.0dip" android:layout_below ="@+id/input" android:gravity ="center" android:textSize ="20dp" android:text = "登录" /> <RelativeLayout android:id ="@+id/relative" android:layout_width ="fill_parent" android:layout_height ="wrap_content" android:layout_alignLeft ="@+id/input" android:layout_alignRight ="@+id/input" android:layout_below ="@id/buton1" > <CheckBox android:id ="@+id/auto_save_password" android:layout_width ="wrap_content" android:layout_height ="wrap_content" android:layout_alignParentLeft ="true" android:background ="@null" android:drawableLeft="@drawable/cpasswd" android:button ="@null" android:checked ="true" android:drawablePadding ="4.0dip" android:text = "记住密码" android:textSize ="12.0sp" /> <Button android:id ="@+id/regist" android:layout_width ="wrap_content" android:layout_height ="wrap_content" android:layout_alignParentRight ="true" android:clickable ="true" android:gravity ="left|center" android:paddingLeft ="8.0dip" android:paddingRight ="18.0dip" android:text = "注册新账号" android:textSize ="12.0sp" /> </RelativeLayout > <LinearLayout android:id ="@+id/more_bottom" android:layout_width ="fill_parent" android:layout_height ="wrap_content" android:layout_alignParentBottom ="true" android:orientation ="vertical" > <RelativeLayout android:id ="@+id/input2" android:layout_width ="fill_parent" android:layout_height ="40dp" android:orientation ="vertical" > <ImageView android:id ="@+id/more_image" android:layout_width ="wrap_content" android:layout_height ="wrap_content" android:layout_centerVertical ="true" android:layout_marginRight ="5.0dip" android:layout_toLeftOf ="@+id/more_text" android:clickable ="false"/> <TextView android:id ="@+id/more_text" android:layout_width ="wrap_content" android:layout_height ="wrap_content" android:layout_centerInParent ="true" android:background ="@null" android:gravity ="center" android:maxLines ="1" android:text = "更多登陆选项" android:textSize ="14.0sp" /> </RelativeLayout > <LinearLayout android:id ="@+id/morehidebottom" android:layout_width ="fill_parent" android:layout_height ="wrap_content" android:orientation ="vertical" android:visibility ="gone" > <View android:layout_width ="fill_parent" android:layout_height ="1.0px" android:background ="#ff005484" /> <View android:layout_width ="fill_parent" android:layout_height ="1.0px" android:background ="#ff0883cb" /> <LinearLayout android:layout_width ="fill_parent" android:layout_height ="wrap_content" android:layout_marginLeft ="30.0dip" android:layout_marginRight ="30.0dip" android:layout_marginTop ="12.0dip" android:orientation ="horizontal" > <CheckBox android:id ="@+id/hide_login" android:layout_width ="1.0px" android:layout_height ="wrap_content" android:layout_weight ="2.0" android:background ="@null" android:drawableLeft="@drawable/checkbox" android:button ="@null" android:checked ="false" android:drawablePadding ="4.0dip" android:text = "隐身登陆" android:textSize ="12.0sp" /> <CheckBox android:id ="@+id/silence_login" android:layout_width ="1.0px" android:layout_height ="wrap_content" android:drawableLeft="@drawable/checkbox" android:layout_weight ="1.0" android:background ="@null" android:button ="@null" android:checked ="false" android:drawablePadding ="4.0dip" android:text = "静音登录" android:textSize ="12.0sp" /> </LinearLayout> <LinearLayout android:layout_width ="fill_parent" android:layout_height ="wrap_content" android:layout_marginBottom ="18.0dip" android:layout_marginLeft ="30.0dip" android:layout_marginRight ="30.0dip" android:layout_marginTop ="18.0dip" android:orientation ="horizontal" > <CheckBox android:id ="@+id/accept_accounts" android:layout_width ="1.0px" android:layout_height ="wrap_content" android:drawableLeft="@drawable/checkbox" android:layout_weight ="2.0" android:background ="@null" android:button ="@null" android:checked ="true" android:drawablePadding ="4.0dip" android:singleLine ="true" android:text = "允许手机/电脑同时在心线" android:textSize ="12.0sp" /> <CheckBox android:id ="@+id/accept_troopmsg" android:layout_width ="1.0px" android:layout_height ="wrap_content" android:drawableLeft="@drawable/checkbox" android:layout_weight ="1.0" android:background ="@null" android:button ="@null" android:checked ="true" android:drawablePadding ="4.0dip" android:text = "接受群消息" android:textSize ="12.0sp" /> </LinearLayout> </LinearLayout> </LinearLayout > </RelativeLayout>登录界面对应的Activity:
public class LoginActivity extends Activity implements OnClickListener { private Button login_Button; private View moreHideBottomView, input2; private ImageView more_imageView; private boolean mShowBottom = false; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); } private void initView() { login_Button = (Button) findViewById(R.id.buton1); login_Button.setOnClickListener(this); moreHideBottomView = findViewById(R.id.morehidebottom); more_imageView = (ImageView) findViewById(R.id.more_image); input2 = findViewById(R.id.input2); input2.setOnClickListener(this); } public void showBottom(boolean bShow) { if (bShow) { moreHideBottomView.setVisibility(View.GONE); //more_imageView.setImageResource(R.drawable.login_more_up); mShowBottom = true; } else { moreHideBottomView.setVisibility(View.VISIBLE); //more_imageView.setImageResource(R.drawable.login_more); mShowBottom = false; } } public void onClick(View v) { switch (v.getId()) { case R.id.input2: showBottom(!mShowBottom); break; case R.id.buton1: break; default: break; } } @Override public boolean onCreateOptionsMenu(Menu menu) { //getMenuInflater().inflate(R.menu.activity_qq, menu); return true; } }
相关文章推荐
- Android客户端之“微服私访”App的系统学习(二)TextInputLayout实现登录界面和LitePal初始化本地数据库
- Android 记住密码和自动登录界面的实现(SharedPreferences 的用法) .
- 仿爱乐透android客户端界面实现(附工程源码)
- Android仿人人客户端(v5.7.1)——欢迎和导引界面的编码实现
- Google用户登录界面 Android实现
- AndroidUI之登录界面的实现分析
- Android开发实例之miniTwitter登录界面的实现
- Android 记住密码和自动登录界面的实现(SharedPreferences 的用法)
- android 集合SSH服务端实现登录并保持session使客户端在登陆后能够获取服务端数据
- Android客户端写Cookie和内嵌的网页实现登录状态的同步
- Android登录界面用SharedPreferences实现记住密码功能
- Android实现登录界面键盘不遮挡登录按钮
- Android实现登录界面和功能实例
- Android 客户端扫描网页端二维码实现登录
- 利用半透明对话框实现新浪微博android客户端首次运行时的提示界面
- 实习日志(12):Android客户端向服务器端传值——登录实现(一)
- android客户端和servlet服务端的简单登录实现
- Android仿网易客户端实现抽屉式拖拉菜单界面
- Lance老师UI系列教程第三课->QQ登录注册界面的实现(android-2012最新版)
- Android实现通用的ActivityGroup(效果类似Android微博客户端主界面),强烈建议不要再使用TabActivity