Android仿QQ登陆窗口实现原理

今天根据腾讯qq,我们做一个练习,来学习如何制作一个漂亮的布局。首先看一下官方图片

还是一个启动画面,之后进入登录页面,导航页面就不介绍了,大家可以参考微信的导航页面。首先程序进入SplashActivity,就是启动页面,Activity代码如下:

package com.example.imitateqq;

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

import android.os.Handler;

public class SplashActivity extends Activity {

private Intent intent;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.splash);

startMainAvtivity();

}

private void startMainAvtivity() {

new Handler().postDelayed(new Runnable() {

public void run() {

intent=new Intent(SplashActivity.this,QQ.class);

startActivity(intent);

SplashActivity.this.finish();//结束本Activity

}

}, 1000);//设置执行时间

}

}

xml布局文件就是一个全屏的图片,要注意的是设置android:scaleType="matrix"这个属性。不然不会全屏

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 ="match_parent"

android:layout_height ="match_parent"

android:scaleType ="matrix"

android:src ="@drawable/splash" />

LinearLayout>

过1秒之后转入登陆页面,从图片我们可以看出,腾讯的UI做的还是相当美观漂亮的,既简洁又不失美观。先分析一下这个登录界面,从整体可以看出,根布局的背景色是蓝色的,而那个QQ 2012 Android其实是一个图片背景色和根布局的背景色一样,这样就不会有视觉偏差。下面就是两个文本框EditText了,注意这里和官方给的不一样,因为后面有一个小箭头,当点击这个箭头时,会在第一个文本框的下面显示已经输入的qq号码,在qq号码的后面还有删除qq信息的按钮。这个地方需要注意一下。再往下就是登陆Button以及那连个“记住密码”和“注册新账号”比较简单,注意位置的安排即可。最后就是最下面的“更多登陆选项”,当点击的时候会向上弹出一些内容,其实就是一个隐藏的布局,当点击上面的时候,使下面隐藏的布局显示。当然也可以使用滑动抽屉来做,但是相对来说比较麻烦。下面看一下xml代码,相信大家就会一路了然。

< 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:background= "@drawable/login_bg" >

< ImageView

android:id ="@+id/loginbutton"

android:layout_width ="wrap_content"

android:layout_height ="wrap_content"

android:layout_centerHorizontal ="true"

android:layout_marginTop ="50dp"

android:src ="@drawable/login_pic" />

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:background ="@drawable/login_input"

android:orientation ="vertical" >

< LinearLayout

android:layout_width ="fill_parent"

android:layout_height ="44.0dip"

android:background ="@drawable/login_input"

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: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:background ="@drawable/login_input_arrow"

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:background ="#00ffffff"

android:gravity ="center_vertical"

android:inputType ="textPassword"

android:maxLength ="16"

android:maxLines ="1"

android:textColor ="#ff1d1d1d"

android:textColorHint ="#ff666666"

android:textSize ="16.0sp" />

android:id ="@+id/buton1"

android:layout_width ="270dp"

android:background ="@drawable/chat_send_button_bg"

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 = "登录" />

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:button ="@null"

android:checked ="true"

android:drawableLeft ="@drawable/checkbox_bg1"

android:drawablePadding ="4.0dip"

android:text = "记住密码"

android:textColor ="#ffffffff"

android:textSize ="12.0sp" />

< Button

android:id ="@+id/regist"

android:layout_width ="wrap_content"

android:layout_height ="wrap_content"

android:layout_alignParentRight ="true"

android:background ="@drawable/login_reg_normal"

android:clickable ="true"

android:gravity ="left|center"

android:paddingLeft ="8.0dip"

android:paddingRight ="18.0dip"

android:text = "注册新账号"

android:textColor ="#ffffffff"

android:textSize ="12.0sp" />

android:id ="@+id/more_bottom"

android:layout_width ="fill_parent"

android:layout_height ="wrap_content"

android:layout_alignParentBottom ="true"

android:background ="@drawable/login_moremenu_back"

android:orientation ="vertical" >

android:id ="@+id/input2"

android:layout_width ="fill_parent"

android:layout_height ="40dp"

android:background ="@drawable/login_moremenu_back"

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"

android:src ="@drawable/login_more_up" />

< 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:textColor ="#ffc6e6f9"

android:textSize ="14.0sp" />

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:button ="@null"

android:checked ="false"

android:drawableLeft ="@drawable/checkbox_bg1"

android:drawablePadding ="4.0dip"

android:text = "隐身登陆"

android:textColor ="#ffc6e6f9"

android:textSize ="12.0sp" />

< CheckBox

android:id ="@+id/silence_login"

android:layout_width ="1.0px"

android:layout_height ="wrap_content"

android:layout_weight ="1.0"

android:background ="@null"

android:button ="@null"

android:checked ="false"

android:drawableLeft ="@drawable/checkbox_bg1"

android:drawablePadding ="4.0dip"

android:text = "静音登录"

android:textColor ="#ffc6e6f9"

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:layout_weight ="2.0"

android:background ="@null"

android:button ="@null"

android:checked ="true"

android:drawableLeft ="@drawable/checkbox_bg1"

android:drawablePadding ="4.0dip"

android:singleLine ="true"

android:text = "允许手机/电脑同时在心线"

android:textColor ="#ffc6e6f9"

android:textSize ="12.0sp" />

< CheckBox

android:id ="@+id/accept_troopmsg"

android:layout_width ="1.0px"

android:layout_height ="wrap_content"

android:layout_weight ="1.0"

android:background ="@null"

android:button ="@null"

android:checked ="true"

android:drawableLeft ="@drawable/checkbox_bg1"

android:drawablePadding ="4.0dip"

android:text = "接受群消息"

android:textColor ="#ffc6e6f9"

android:textSize ="12.0sp" />

LinearLayout>

LinearLayout>

RelativeLayout>

各个组件的使用没有问题,关键是如何设置他们的属性,来获得一个比较美观的效果,大家可以参考这个例子,来做一下练习,来强化UI的设计。从这个例子中就可以学到很多东西,比如ViwGroup的使用(如何枪套),background的设置,例如同时使用两个Edittext,设置android:background="@null"设置为空的时候就不会产生间隔了。这个要自己多做设计,时间长了就会有感悟了。最后看一下MainActivity的代码,布局简单package com.example.imitateqq;

import android.os.Bundle;

import android.app.Activity;

import android.app.Dialog;

import android.view.Menu;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.ImageView;

public class QQ 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_qq);

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:

showRequestDialog();

break;

default:

break;

}

}

private Dialog mDialog = null;

private void showRequestDialog()

{

if (mDialog != null)

{

mDialog.dismiss();

mDialog = null;

}

mDialog = DialogFactory.creatRequestDialog(this, "正在验证账号...");

mDialog.show();

}

@Override

public boolean onCreateOptionsMenu(Menu menu) {

getMenuInflater().inflate(R.menu.activity_qq, menu);

return true;

}

}最后效果如下:

总结:本文可以作为一个UI练习Demo,大家可以自己独立去写,有问题的可以留下邮箱我给你发一下源码作为参考。下一篇将写主页面的实现,欢迎大家关注。相关阅读:

惊!盗版Win10升级后仍然是盗版

ThinkPHP提交表单时默认自动转义的解决方法

详解Linux下常用远程登陆命令telnet和rlogin的用法

Android中RecyclerView实现横向滑动代码

js分页工具实例

PHP curl伪造IP地址和header信息代码实例

JavaScript实现维吉尼亚(Vigenere)密码算法实例

php中限制ip段访问、禁止ip提交表单的代码分享

jquery cookie的用法总结

php+xml实现在线英文词典查询的方法

JQuery选择器、过滤器大整理

PHP中比较时间大小实例

Android控件之EditView常用属性及应用方法

php使用Cookie实现和用户会话的方法

php仿qq登录界面安卓,Android_Android仿QQ登陆窗口实现原理,今天根据腾讯qq,我们做一个 - phpStudy...相关推荐

  1. 仿 qq登录界面 php,js仿腾讯QQ的web登陆界面

    用了腾讯QQ也有将近十年了,今天心血来潮想模仿腾讯QQ的登陆面板做一个web版的登陆面板,然后参考了一些代码,自己模仿,学写了一个. 效果如下: 其中还实现了拖动面板,选择状态的效果 下面是具体代码: ...

  2. ios 仿电脑qq登录界面_高仿Windows Phone QQ登录界面实例代码

    给 TextBox文本框前添加图片 扩展PhoneTextBox:添加一个类"ExtentPhoneTextBox"继承 PhoneTextBox ,在"ExtentPh ...

  3. java仿qq登录 界面设计,Java Swing仿QQ登录界面效果

    本文实例为大家分享了Java Swing仿QQ登录界面展示的具体代码,供大家参考,具体内容如下 闲来无事将早些时候已实现的QQ登录界面再实现了一遍,纯手工打造(意思是没有用NetBeans.MyEcl ...

  4. java如何引入qq登陆,Java Swing仿QQ登录界面 学习之用

    闲来无事将早些时候已实现的QQ登录界面再实现了一遍,纯手工打造(意思是没有用NetBeans.MyEclipse的拖动功能). 源代码如下: package ibees.qq; import java ...

  5. java gui界面设计qq_Java swing界面开发(仿QQ登录界面)

    首先引入包的概念,包:给代码分类,提高的了代码的可读性,封装后方便管理.在包中类的引入:import 包名.类名;包名需小写,多单词用"."隔开.类名的命名规范:首字母大写其后的每 ...

  6. Android UI布局—— 仿QQ登录界面

    最近,有点空闲的时间就拿QQ登录界面来模仿练手,做了个简单的登录界面.界面一般般吧,不算很漂亮,现在拿出来分享,希望大家一起学习与进步.有什么不足之处,请各位大侠多多赐教,谢谢.这个界面涉及到Line ...

  7. ios 仿电脑qq登录界面_iOS开发UI篇—模仿ipad版QQ空间登录界面

    iOS开发UI篇-模仿ipad版QQ空间登录界面 一.实现和步骤 1.一般ipad项目在命名的时候可以加一个HD,标明为高清版 2.设置项目的文件结构,分为home和login两个部分 3.登陆界面的 ...

  8. JavaSwing仿QQ登录界面,注释完善,适合新手学习

    使用说明: 这是一个java做的仿制QQ登录界面,界面仅使用一个类, JDK版本为jdk-11 素材包的名字为:素材(下载)请在项目中新建一个名字为"素材"的文件夹. 素材: ht ...

  9. 详解使用NetBeans IDE 8.2进行可视化图形界面设计——高仿QQ登录界面

    目录 前言 QQ登录界面的设计与实现 1.新建一个Java项目 2.在任意包下新建一个JFrame窗体类 3.添加图片 4.设置账号文本框(JTextField)与密码框(JPasswordField ...

最新文章

  1. 极客新闻——16、数据库设计中的5个常见错误
  2. Spring中ClassPathXmlApplicationContext类的简单使用
  3. Linux下Hadoop hdfs Java API使用
  4. 钉钉扫码登录第三方_在钉钉发布公司重要文件,真的安全吗?
  5. try not let others think you are good enough
  6. 机器学习问题总结(03)
  7. c++语言怎么从internet上某个时间服务器获取时间信息,在VC++中实现同步Internet时间...
  8. dns设置邮箱服务器,专业版DNS设置-更多-Coremail论客邮件系统-企业邮箱,8亿用户信赖的邮件服务器系统...
  9. 鲜为人知的软件项目管理原则
  10. 程序员面试宝典(一) - 流程概览
  11. Unity3D 导入资源
  12. 米尔MYD-JX8MPQ yocto 编译流程 (记录)
  13. 设备功耗计算专题《低功耗实战篇,全志XR808连接AP的最低功耗研究》
  14. WordPress主题justnews仿某码屋资源下载站源码-整站打包
  15. 心理学效应:阿基米德与酝酿效应
  16. 宝宝性别测试软件,胎儿性别测试方法
  17. 整理的最新的前端面试题必问集锦 (持续更新)
  18. 检测和缓解PLC恶意软件的过程计算方法
  19. C++ 之父 Bjarne Stroustrup : 简单的表述方式才是最优的方案
  20. 在电脑上安装了百度一键root工具后,启动adb提示:adb server version (31) doesn't match this client (36); killing...

热门文章

  1. Linux 用ssh远程登录及scp传输文件
  2. 声明$(function(){})的含义
  3. 解决Docker镜像缺少字体的问题
  4. python爬虫(四)cookie模拟登录和反反爬案例
  5. 微服务化小团队:让 GitLab、Jenkins 与 Sonar 碰撞出火花
  6. C# ComboBox:组合框控件
  7. 动态创建style标签样式
  8. postgresql-9.5.5数据库安装教程
  9. PHP:include包含文件局部引入全局变量失效的作用域问题
  10. 微信协议pc微信协议