制作QQ登录界面,vue数据双向绑定

实验步骤

==============================================================

1.程序大致理解


在构建UI界面时不要着急动手,首先要考虑准备哪些素材

《Android学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》

【docs.qq.com/doc/DSkNLaERkbnFoS0ZF】 完整内容开源分享

(如:图片资源),会用到哪些控件,把步骤想清楚再动手实践,养成良好的编程习惯在以后开发中会有很大帮助。现在先来看一下QQ登录界面,预览效果如下图所示。

制作QQ登录界面,vue数据双向绑定

从图中可以看出,该界面需要一张图片作为QQ头像,因此找到1张图片(head.png)放在drawable文件夹中。制作QQ登录界面,vue数据双向绑定

然后分析该界面组成部分,从整体来看界面可分为三部分,第一部分放置1个ImageView控件用于显示头像。制作QQ登录界面,vue数据双向绑定

第二部分使用两个水平的线性布局,每个水平布局放置1个TextView控件和1个EditText控件,分别用于显示标题和输入内容。制作QQ登录界面,vue数据双向绑定

第三部分放置1个Button按钮用于实现登录。制作QQ登录界面,vue数据双向绑定

2.代码实现


总的布局是RelativeLayout

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android”

xmlns:app=“http://schemas.android.com/apk/res-auto”

xmlns:tools=“http://schemas.android.com/tools”

android:layout_width=“match_parent”

android:layout_height=“match_parent”

tools:context=".MainActivity"

android:orientation=“vertical”>

第一部分的ImageView控件用来存放QQ头像

<ImageView

android:id="@+id/iv"

android:layout_width=“70dp”

android:layout_height=“70dp”

android:layout_centerHorizontal=“true”

android:layout_marginTop=“40dp”

android:background="@drawable/head"/>

第二部分使用两个水平的线性布局,每个水平布局有1个TextView控件和1个EditView控件,分别用来显示标题和输入内容

<LinearLayout

android:id="@+id/ll_number"

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:layout_below="@+id/iv"

android:layout_centerHorizontal=“true”

android:layout_marginBottom=“5dp”

android:layout_marginLeft=“10dp”

android:layout_marginRight=“10dp”

android:layout_marginTop=“15dp”

android:background="#ffffff">

<TextView

android:id="@+id/tv_number"

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:padding=“10dp”

android:text=“账号:”

android:textColor="#000"

android:textSize=“20sp”/>

<EditText

android:id="@+id/et_number"

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:layout_marginLeft=“5dp”

android:background="@null"

android:padding=“10dp”/>

<LinearLayout

android:id="@+id/ll_password"

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:layout_below="@+id/ll_number"

android:layout_centerVertical=“true”

android:layout_marginLeft=“10dp”

android:layout_marginRight=“10dp”

android:background="#ffffff">

<TextView

android:id="@+id/tv_password"

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:padding=“10dp”

android:text=“密码:”

android:textColor="#000"

android:textSize=“20sp”/>

<EditText

android:id="@+id/et_password"

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:layout_marginLeft=“5dp”

android:layout_toRightOf="@id/tv_password"

上一篇:Java实现邮件发送(QQ邮箱例)


下一篇:QQ堂5.2下载——纪念我们终将逝去的童年