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

还是一个启动画面,之后进入登录页面,导航页面就不介绍了,大家可以参考微信的导航页面。首先程序进入SplashActivity,就是启动页面,Activity代码如下:
[java]  view plain copy
  1. package com.example.imitateqq;
  2. import android.app.Activity;
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.os.Handler;
  6. public class SplashActivity extends Activity {
  7. private Intent intent;
  8. @Override
  9. protected void onCreate(Bundle savedInstanceState) {
  10. super.onCreate(savedInstanceState);
  11. setContentView(R.layout.splash);
  12. startMainAvtivity();
  13. }
  14. private void startMainAvtivity() {
  15. new Handler().postDelayed(new Runnable() {
  16. public void run() {
  17. intent=new Intent(SplashActivity.this,QQ.class);
  18. startActivity(intent);
  19. SplashActivity.this.finish();//结束本Activity
  20. }
  21. }, 1000);//设置执行时间
  22. }
  23. }
xml布局文件就是一个全屏的图片,要注意的是设置 android:scaleType ="matrix"这个属性。不然不会全屏
[html]  view plain copy
  1. <? xml version= "1.0" encoding = "utf-8"?>
  2. < LinearLayout xmlns:android ="http://schemas.android.com/apk/res/android"
  3. android:layout_width= "match_parent"
  4. android:layout_height= "match_parent"
  5. android:orientation= "vertical" >
  6. < ImageView
  7. android:layout_width ="match_parent"
  8. android:layout_height ="match_parent"
  9. android:scaleType ="matrix"
  10. android:src ="@drawable/splash" />
  11. </ LinearLayout>
过1秒之后转入登陆页面,从图片我们可以看出,腾讯的UI做的还是相当美观漂亮的,既简洁又不失美观。先分析一下这个登录界面,从整体可以看出,根布局的背景色是蓝色的,而那个QQ 2012 Android其实是一个图片背景色和根布局的背景色一样,这样就不会有视觉偏差。下面就是两个文本框EditText了,注意这里和官方给的不一样,因为后面有一个小箭头,当点击这个箭头时,会在第一个文本框的下面显示已经输入的qq号码,在qq号码的后面还有删除qq信息的按钮。这个地方需要注意一下。再往下就是登陆Button以及那连个“记住密码”和“注册新账号”比较简单,注意位置的安排即可。最后就是最下面的“更多登陆选项”,当点击的时候会向上弹出一些内容,其实就是一个隐藏的布局,当点击上面的时候,使下面隐藏的布局显示。当然也可以使用滑动抽屉来做,但是相对来说比较麻烦。下面看一下xml代码,相信大家就会一路了然。
[html]  view plain copy
  1. < RelativeLayout xmlns:android ="http://schemas.android.com/apk/res/android"
  2. xmlns:tools= "http://schemas.android.com/tools"
  3. android:layout_width= "match_parent"
  4. android:layout_height= "match_parent"
  5. android:background= "@drawable/login_bg" >
  6. < ImageView
  7. android:id ="@+id/loginbutton"
  8. android:layout_width ="wrap_content"
  9. android:layout_height ="wrap_content"
  10. android:layout_centerHorizontal ="true"
  11. android:layout_marginTop ="50dp"
  12. android:src ="@drawable/login_pic" />
  13. <LinearLayout
  14. android:id ="@+id/input"
  15. android:layout_width ="fill_parent"
  16. android:layout_height ="wrap_content"
  17. android:layout_below ="@id/loginbutton"
  18. android:layout_marginLeft ="28.0dip"
  19. android:layout_marginRight ="28.0dip"
  20. android:background ="@drawable/login_input"
  21. android:orientation ="vertical" >
  22. < LinearLayout
  23. android:layout_width ="fill_parent"
  24. android:layout_height ="44.0dip"
  25. android:background ="@drawable/login_input"
  26. android:gravity ="center_vertical"
  27. android:orientation ="horizontal" >
  28. < EditText
  29. android:id ="@+id/searchEditText"
  30. android:layout_width ="0dp"
  31. android:layout_height ="fill_parent"
  32. android:layout_weight ="1"
  33. android:background ="@null"
  34. android:ems ="10"
  35. android:imeOptions ="actionDone"
  36. android:singleLine ="true"
  37. android:textSize ="16sp" >
  38. < requestFocus />
  39. </ EditText>
  40. < Button
  41. android:id ="@+id/button_clear"
  42. android:layout_width ="20dip"
  43. android:layout_height ="20dip"
  44. android:layout_marginRight ="8dip"
  45. android:background ="@drawable/login_input_arrow"
  46. android:visibility ="visible" />
  47. </ LinearLayout>
  48. < View
  49. android:layout_width ="fill_parent"
  50. android:layout_height ="1.0px"
  51. android:layout_marginLeft ="1.0px"
  52. android:layout_marginRight ="1.0px"
  53. android:background ="#ffc0c3c4" />
  54. < EditText
  55. android:id ="@+id/password"
  56. android:layout_width ="fill_parent"
  57. android:layout_height ="44.0dip"
  58. android:background ="#00ffffff"
  59. android:gravity ="center_vertical"
  60. android:inputType ="textPassword"
  61. android:maxLength ="16"
  62. android:maxLines ="1"
  63. android:textColor ="#ff1d1d1d"
  64. android:textColorHint ="#ff666666"
  65. android:textSize ="16.0sp" />
  66. </LinearLayout >
  67. <Button
  68. android:id ="@+id/buton1"
  69. android:layout_width ="270dp"
  70. android:background ="@drawable/chat_send_button_bg"
  71. android:paddingTop ="5.0dip"
  72. android:layout_height ="50dp"
  73. android:layout_marginLeft ="28.0dip"
  74. android:layout_marginRight ="28.0dip"
  75. android:layout_marginTop ="12.0dip"
  76. android:layout_below ="@+id/input"
  77. android:gravity ="center"
  78. android:textSize ="20dp"
  79. android:text = "登录" />
  80. <RelativeLayout
  81. android:id ="@+id/relative"
  82. android:layout_width ="fill_parent"
  83. android:layout_height ="wrap_content"
  84. android:layout_alignLeft ="@+id/input"
  85. android:layout_alignRight ="@+id/input"
  86. android:layout_below ="@id/buton1" >
  87. < CheckBox
  88. android:id ="@+id/auto_save_password"
  89. android:layout_width ="wrap_content"
  90. android:layout_height ="wrap_content"
  91. android:layout_alignParentLeft ="true"
  92. android:background ="@null"
  93. android:button ="@null"
  94. android:checked ="true"
  95. android:drawableLeft ="@drawable/checkbox_bg1"
  96. android:drawablePadding ="4.0dip"
  97. android:text = "记住密码"
  98. android:textColor ="#ffffffff"
  99. android:textSize ="12.0sp" />
  100. < Button
  101. android:id ="@+id/regist"
  102. android:layout_width ="wrap_content"
  103. android:layout_height ="wrap_content"
  104. android:layout_alignParentRight ="true"
  105. android:background ="@drawable/login_reg_normal"
  106. android:clickable ="true"
  107. android:gravity ="left|center"
  108. android:paddingLeft ="8.0dip"
  109. android:paddingRight ="18.0dip"
  110. android:text = "注册新账号"
  111. android:textColor ="#ffffffff"
  112. android:textSize ="12.0sp" />
  113. </RelativeLayout >
  114. <LinearLayout
  115. android:id ="@+id/more_bottom"
  116. android:layout_width ="fill_parent"
  117. android:layout_height ="wrap_content"
  118. android:layout_alignParentBottom ="true"
  119. android:background ="@drawable/login_moremenu_back"
  120. android:orientation ="vertical" >
  121. <RelativeLayout
  122. android:id ="@+id/input2"
  123. android:layout_width ="fill_parent"
  124. android:layout_height ="40dp"
  125. android:background ="@drawable/login_moremenu_back"
  126. android:orientation ="vertical" >
  127. < ImageView
  128. android:id ="@+id/more_image"
  129. android:layout_width ="wrap_content"
  130. android:layout_height ="wrap_content"
  131. android:layout_centerVertical ="true"
  132. android:layout_marginRight ="5.0dip"
  133. android:layout_toLeftOf ="@+id/more_text"
  134. android:clickable ="false"
  135. android:src ="@drawable/login_more_up" />
  136. < TextView
  137. android:id ="@+id/more_text"
  138. android:layout_width ="wrap_content"
  139. android:layout_height ="wrap_content"
  140. android:layout_centerInParent ="true"
  141. android:background ="@null"
  142. android:gravity ="center"
  143. android:maxLines ="1"
  144. android:text = "更多登陆选项"
  145. android:textColor ="#ffc6e6f9"
  146. android:textSize ="14.0sp" />
  147. </RelativeLayout >
  148. <LinearLayout
  149. android:id ="@+id/morehidebottom"
  150. android:layout_width ="fill_parent"
  151. android:layout_height ="wrap_content"
  152. android:orientation ="vertical"
  153. android:visibility ="gone" >
  154. < View
  155. android:layout_width ="fill_parent"
  156. android:layout_height ="1.0px"
  157. android:background ="#ff005484" />
  158. < View
  159. android:layout_width ="fill_parent"
  160. android:layout_height ="1.0px"
  161. android:background ="#ff0883cb" />
  162. < LinearLayout
  163. android:layout_width ="fill_parent"
  164. android:layout_height ="wrap_content"
  165. android:layout_marginLeft ="30.0dip"
  166. android:layout_marginRight ="30.0dip"
  167. android:layout_marginTop ="12.0dip"
  168. android:orientation ="horizontal" >
  169. < CheckBox
  170. android:id ="@+id/hide_login"
  171. android:layout_width ="1.0px"
  172. android:layout_height ="wrap_content"
  173. android:layout_weight ="2.0"
  174. android:background ="@null"
  175. android:button ="@null"
  176. android:checked ="false"
  177. android:drawableLeft ="@drawable/checkbox_bg1"
  178. android:drawablePadding ="4.0dip"
  179. android:text = "隐身登陆"
  180. android:textColor ="#ffc6e6f9"
  181. android:textSize ="12.0sp" />
  182. < CheckBox
  183. android:id ="@+id/silence_login"
  184. android:layout_width ="1.0px"
  185. android:layout_height ="wrap_content"
  186. android:layout_weight ="1.0"
  187. android:background ="@null"
  188. android:button ="@null"
  189. android:checked ="false"
  190. android:drawableLeft ="@drawable/checkbox_bg1"
  191. android:drawablePadding ="4.0dip"
  192. android:text = "静音登录"
  193. android:textColor ="#ffc6e6f9"
  194. android:textSize ="12.0sp" />
  195. </ LinearLayout>
  196. < LinearLayout
  197. android:layout_width ="fill_parent"
  198. android:layout_height ="wrap_content"
  199. android:layout_marginBottom ="18.0dip"
  200. android:layout_marginLeft ="30.0dip"
  201. android:layout_marginRight ="30.0dip"
  202. android:layout_marginTop ="18.0dip"
  203. android:orientation ="horizontal" >
  204. < CheckBox
  205. android:id ="@+id/accept_accounts"
  206. android:layout_width ="1.0px"
  207. android:layout_height ="wrap_content"
  208. android:layout_weight ="2.0"
  209. android:background ="@null"
  210. android:button ="@null"
  211. android:checked ="true"
  212. android:drawableLeft ="@drawable/checkbox_bg1"
  213. android:drawablePadding ="4.0dip"
  214. android:singleLine ="true"
  215. android:text = "允许手机/电脑同时在心线"
  216. android:textColor ="#ffc6e6f9"
  217. android:textSize ="12.0sp" />
  218. < CheckBox
  219. android:id ="@+id/accept_troopmsg"
  220. android:layout_width ="1.0px"
  221. android:layout_height ="wrap_content"
  222. android:layout_weight ="1.0"
  223. android:background ="@null"
  224. android:button ="@null"
  225. android:checked ="true"
  226. android:drawableLeft ="@drawable/checkbox_bg1"
  227. android:drawablePadding ="4.0dip"
  228. android:text = "接受群消息"
  229. android:textColor ="#ffc6e6f9"
  230. android:textSize ="12.0sp" />
  231. </ LinearLayout>
  232. </ LinearLayout>
  233. </LinearLayout >
  234. </ RelativeLayout>
 各个组件的使用没有问题,关键是如何设置他们的属性,来获得一个比较美观的效果,大家可以参考这个例子,来做一下练习,来强化UI的设计。从这个例子中就可以学到很多东西,比如ViwGroup的使用(如何枪套), background的设置,例如同时使用两个Edittext,设置 android:background  = "@null"设置为空的时候就不会产生间隔了。这个要自己多做设计,时间长了就会有感悟了。最后看一下MainActivity的代码,布局简单
[java]  view plain copy
  1. package com.example.imitateqq;
  2. import android.os.Bundle;
  3. import android.app.Activity;
  4. import android.app.Dialog;
  5. import android.view.Menu;
  6. import android.view.View;
  7. import android.view.View.OnClickListener;
  8. import android.widget.Button;
  9. import android.widget.ImageView;
  10. public class QQ extends Activity implements OnClickListener{
  11. private Button login_Button;
  12. private View moreHideBottomView,input2;
  13. private ImageView more_imageView;
  14. private boolean mShowBottom = false;
  15. @Override
  16. public void onCreate(Bundle savedInstanceState) {
  17. super.onCreate(savedInstanceState);
  18. setContentView(R.layout.activity_qq);
  19. initView();
  20. }
  21. private void initView() {
  22. login_Button=(Button) findViewById(R.id.buton1);
  23. login_Button.setOnClickListener(this);
  24. moreHideBottomView=findViewById(R.id.morehidebottom);
  25. more_imageView=(ImageView) findViewById(R.id.more_image);
  26. input2=findViewById(R.id.input2);
  27. input2.setOnClickListener( this);
  28. }
  29. public void showBottom(boolean bShow){
  30. if(bShow){
  31. moreHideBottomView.setVisibility(View.GONE);
  32. more_imageView.setImageResource(R.drawable.login_more_up);
  33. mShowBottom = true;
  34. }else{
  35. moreHideBottomView.setVisibility(View.VISIBLE);
  36. more_imageView.setImageResource(R.drawable.login_more);
  37. mShowBottom = false;
  38. }
  39. }
  40. public void onClick(View v) {
  41. switch(v.getId())
  42. {
  43. case R.id.input2:
  44. showBottom(!mShowBottom);
  45. break;
  46. case R.id.buton1:
  47. showRequestDialog();
  48. break;
  49. default:
  50. break;
  51. }
  52. }
  53. private Dialog mDialog = null;
  54. private void showRequestDialog()
  55. {
  56. if (mDialog != null)
  57. {
  58. mDialog.dismiss();
  59. mDialog = null;
  60. }
  61. mDialog = DialogFactory.creatRequestDialog(this, "正在验证账号...");
  62. mDialog.show();
  63. }
  64. @Override
  65. public boolean onCreateOptionsMenu(Menu menu) {
  66. getMenuInflater().inflate(R.menu.activity_qq, menu);
  67. return true;
  68. }
  69. }
最后效果如下:
总结:本文可以作为一个UI练习Demo,大家可以自己独立去写,有问题的可以留下邮箱我给你发一下源码作为参考。下一篇将写主页面的实现,欢迎大家关注。
代码下载

(四)Android仿微信—仿QQ登陆相关推荐

  1. android 加号弹出菜单,Android仿微信、qq点击右上角加号弹出操作框

    Android仿微信.qq点击右上角加号弹出操作框,先上图,类似于下图这种,点击加号,会弹出一个对话框,如下图: 微信: 自己实现: 接下来,我们来实现此功能: 其实,实现原理就是,点击"+ ...

  2. Android自定义弹窗模仿微信,Android仿微信、qq点击右上角加号弹出操作框

    Android仿微信.qq点击右上角加号弹出操作框,先上图,类似于下图这种,点击加号,会弹出一个对话框,如下图: 微信: 自己实现: 接下来,我们来实现此功能: 其实,实现原理就是,点击"+ ...

  3. android 仿qq群头像,Android仿微信和QQ多图合并框架(类似群头像)的实现方法

    Android仿微信和QQ多图合并框架(类似群头像)的实现方法 发布时间:2020-10-21 10:33:03 来源:脚本之家 阅读:97 作者:jyb_96 前言 现在多数app里面加入聊天已经是 ...

  4. 聊天气泡框模块源码 (高仿微信、QQ聊天的气泡聊天框)

    模块名称:聊天气泡框 (易语言模块) 模块作者:邓学彬(泪闯天涯) 模块说明:高仿微信.QQ聊天的气泡聊天框 模块发布:模块+模块源码+调用例程 实现方法:基于列表框(ListBox)控件,自己计算每 ...

  5. Android 11 微信,QQ ,微博 分享适配

    Android 11 微信,QQ ,微博 分享适配 前言 微信篇 QQ篇 微博篇 前言 最近收到客服反馈 有用户反馈微信分享不了,具体询问一番发现是Android 11的小米机器,然后依次试了 QQ ...

  6. Android仿微信,QQ群头像合成

    原文地址:https://www.jb51.net/article/130296.htm 效果图: 作为程序员,首先会评估下工作量吧.在产品眼里,就是把图片合成一起嘛,有啥难度吗?所以工作时间决定了你 ...

  7. 仿微信,qq组合头像

    参考原文:点击打开链接 从网上找了一些仿微信群聊头像demo,发现是studio编写的,我一直习惯用eclpise,所以参考着完成了eclipse版的, 这个界面是写在适配器里面嵌套的,用法和平时一样 ...

  8. Android 实现微信,QQ的程序前后台切换:back键切换后台;点击通知栏恢复前台。

    实现类似微信,QQ的前后台切换:back键切换后台:点击通知栏恢复前台. 1.back键切换后台的实现: 这个实现需要在主activity重写onbackpressed()方法.代码如下: @Over ...

  9. Android 接收微信、QQ其他应用打开,第三方分享

    这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助 在AndroidManifest.xml注册ACTION事件 <activityandroid:name="com.tes ...

  10. Android友盟集成QQ登陆详解大全

    第一步打开友盟官网注册一个账号,登录如下图进行操作点击个人中心 进入下一个界面点击管理创建一个应用生成AppKey:如下图 返回首页点击SDK与文档点击进行第三方登录集成点击右边的SDK下载选择你需要 ...

最新文章

  1. 如何看懂一个深度学习的项目代码
  2. lsof 查看一个进程打开哪些fd及对应的文件或套接字操作
  3. 神经网络结构与输出值之间的关系
  4. 声学多普勒流速剖面仪_雷达流量计/流速仪厂家有哪些?
  5. 提高国内访问GitHub速度的9种方案~
  6. [react-router] React-Router怎么获取历史对象?
  7. 【HDU - 6016】Count the Sheep (思维,类似二分图)
  8. windows 下安装rabbitmq
  9. python文本文件不能用二进制文件方式读入_如何使用python函数以二进制形式读取文件?...
  10. linux搭建web服务器原理,【LINUX】linux搭建web服务器
  11. [学习笔记]Javascript可选的分号
  12. rhel6下,mysql 5.6.14 主从复制(也称mysql AB复制)环境配置[基于binlog]
  13. HTTP协议和HTTPS协议
  14. Jenkins学习一:Jenkins是什么?
  15. tiobe编程语言排名_排名前20位的编程语言:GitHut和Tiobe排名
  16. AndroidQQ登录
  17. 优雅使用Jsdelivr/CDN加速博客访问速度
  18. 计算机毕业设计ssm+vue基本微信小程序的“香草屋”饮料奶茶点单小程序
  19. 如何让笔记本电脑更省电
  20. NeoVim/SpaceVim初体验

热门文章

  1. android 关于px转化为dp,sp
  2. openwrt配置内核驱动_OpenWrt添加驱动模块
  3. 在电脑上剪辑视频用什么软件 如何在电脑上剪辑视频
  4. 使用lua配置neovim所需的一切
  5. hdmi tv 的edid_HDMI之EDID分析
  6. KTV 歌房如何实现伴奏与人声同步功能
  7. char int word long的大小
  8. 小程序全局拖动悬浮球插件
  9. 原生 js、javaScript 处理十位数(带有小数点的浮点数时间戳)、十三位数、时间戳, 将时间戳转换成 年、月、日、时、分、秒、毫秒、正常的日期格式
  10. 3D游戏之父--John Carmack连载系列(四)