先来一个最简单的     AndroidManifest.xml

<?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"
android:padding="16dp"> <EditText
android:id="@+id/edit_text_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username" /> <EditText
android:id="@+id/edit_text_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword" /> <Button
android:id="@+id/button_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Log in" /> </LinearLayout>

这个没有背景什么的,特别简陋。

接着又写了一个稍微花哨点的。

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"> <ImageView
android:id="@+id/image_logo"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="72dp"
android:src="@drawable/logo" /> <EditText
android:id="@+id/edit_text_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/image_logo"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="48dp"
android:background="@drawable/edit_text_bg"
android:drawableLeft="@drawable/ic_user"
android:drawablePadding="16dp"
android:hint="Username"
android:padding="16dp"
android:textColor="@color/dark_gray"
android:textColorHint="@color/light_gray" /> <EditText
android:id="@+id/edit_text_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/edit_text_username"
android:layout_marginHorizontal="24dp"
android:background="@drawable/edit_text_bg"
android:drawableLeft="@drawable/ic_password"
android:drawablePadding="16dp"
android:hint="Password"
android:inputType="textPassword"
android:padding="16dp"
android:textColor="@color/dark_gray"
android:textColorHint="@color/light_gray" /> <Button
android:id="@+id/button_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/edit_text_password"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="36dp"
android:background="@drawable/button_bg"
android:text="Log in"
android:textColor="@color/white" /> </RelativeLayout>

附加      edit_text_bg.xml,button_bg.xml,colors.xml,background.xml、edit_text_bg.xml、button_bg.xml

  colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="red">#FF0000</color>
<color name="dark_gray">#333333</color>
<color name="light_gray">#CCCCCC</color>
<color name="button_bg_normal">#2196F3</color>
<color name="button_bg_pressed">#1976D2</color>
</resources>

  colors.xml文件应该放在values文件夹中

  background.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> <gradient
android:startColor="#FFC107"
android:endColor="#FF9800"
android:type="linear" /> </shape>

  edit_text_bg.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> <solid android:color="@color/white" /> <corners android:radius="8dp" /> <stroke
android:width="1dp"
android:color="@color/light_gray" /> </shape>

  button_bg.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<gradient
android:startColor="@color/button_bg_pressed"
android:endColor="@color/button_bg_normal"
android:angle="270" /> <corners android:radius="8dp" /> <padding
android:left="16dp"
android:top="12dp"
android:right="16dp"
android:bottom="12dp" />
</shape>
</item> <item>
<shape>
<gradient
android:startColor="@color/button_bg_normal"
android:endColor="@color/button_bg_normal"
android:angle="270" /> <corners android:radius="8dp" /> <padding
android:left="16dp"
android:top="12dp"
android:right="16dp"
android:bottom="12dp" />
</shape>
</item>
</selector>

  background.xml,edit_text_bg.xml和button_bg.xml文件应该放在drawable文件夹中

最后由三张图片,分别是logo,用户图标,密码图标。

  logo.png

在drawable文件夹中放置一张适当大小的Logo图片即可。

  ic_user.png

在drawable文件夹中放置一张适当大小的用户图标图片即可。

  ic_password.png

在drawable文件夹中放置一张适当大小的密码图标图片即可。

最后想让账号只能使用11位手机号,只需替代部分EditText

<EditText
android:id="@+id/et_phone_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/phone_number"
android:inputType="phone"
android:maxLength="11"
android:maxLines="1"
android:textColor="@color/black"
android:textColorHint="@color/gray"
android:textSize="16sp" />

最后提供用户图标和密码图标,logo就随便了,别忘了修改文件名

android studio 做登陆界面的更多相关文章

  1. android studio 新建项目 界面一直停在 【“building ‘ 项目名’ gradle project info”】

    zhezhelin android studio 新建项目 界面一直停在 [“building ‘ 项目名’ gradle project info”] 安装了android studio 之后,按照 ...

  2. 只能用Android studio做平台移植了! 在Windows10下, 开发Android。

    安装好IDE后, 会一直显示同步失败, 看看如下步骤: 需要注意的是: -> 安装NDK      自带的NDK版本有问题    自己去下一个15版本的 -> 按照系统提示一步一步安装其他 ...

  3. android studio 新建项目 界面一直停在 【“building ‘ 项目名’ gradle project info”】

    安装了android studio 之后,按照上文所述的那篇博文下载安装gradle,配置环境变量, 启动android studio,新建项目,发现还是新建不了,界面一直停在 ["buil ...

  4. Android——用对话框做登陆界面(自定义对话框AlertDialog,多线程,进度条ProgressDialog,ListView,GridView,SharedPreferences存,读数据,存取文本,assets文件)

    效果: 1.点击图标进入页面二 2.页面2图片暂停显示5秒进入页面三 3.点击页面三登陆按钮,打开登陆对话框,输入密码进入页面四 点击下载按钮,显示水平进度条 点击保存和获取用户名和密码 进入页面六  ...

  5. Android Studio实现登陆注册功能之手机号验证

    我们平常写的登陆注册功能,就是很普通的注册一个账号,设置密码,然后登录.这次,想写一个与之前稍微不一样的登陆注册界面,于是想到了手机号验证的方式. 现在我们市面上出现的很多app,都是采用的手机号注册 ...

  6. Android studio 简易登录界面

    •参考资料 [1]:视频资源 [2]:Android TextView设置图标,调整图标大小 •效果展示图 •前置知识 TextView EditText Button 以及按压效果,点击事件 •出现 ...

  7. Android零基础入门第12节:熟悉Android Studio界面,开始装逼卖萌

    原文:Android零基础入门第12节:熟悉Android Studio界面,开始装逼卖萌 通过前两期的学习,我们可以正确搭建好Android Studio的开发环境,也创建了HelloWorld工程 ...

  8. 如何通过Android Studio发布library到jCenter和Maven Central

    http://www.jianshu.com/p/3c63ae866e52# 在Android Studio里,如果你想引入任何library到自己的项目中,只需要很简单的在module的build. ...

  9. Android零基础入门第13节:Android Studio配置优化,打造开发利器

    原文:Android零基础入门第13节:Android Studio配置优化,打造开发利器 是不是很多同学已经有烦恼出现了?电脑配置已经很高了,但是每次运行Android程序的时候就很卡,而且每次安装 ...

  10. 导入Eclipse工程 到 Android Studio

    一.从Eclipse导入工程到Android Studio 根据官方的介绍,Android Studio可以兼容Eclipse的现有工程,但需要做一些操作: 首先升级ADT到最新版本,目前为版本号为2 ...

随机推荐

  1. 斐讯K2路由器刷机教程

    为了避免斐讯后门程序. 我用的win10系统 我刷的是华硕的老毛子 Padavan,我放的是压缩包,请解压到桌面! 下载地址: 链接:https://pan.baidu.com/s/1O_spSek- ...

  2. JAVA 学习打卡 day2

    2022-04-23 16:43:32 1.字符类型 (1)字符和整型之间的相互转换 给字符变量赋值可以使用数值和字符,它们都可以使程序正确地运行.要注意的是,字符要用一对单引号('')括起 (2)常 ...

  3. HTTPS的实现原理 ---- 核心 SSL/TLS协议

    是在应用层和 传输层之间 添加的 安全层(SSL/TLS协议) 端口号 :HTTP 默认是 80,HTTPS 默认是 443. URL 前缀 :HTTP 的 URL 前缀是 http://,HTTPS ...

  4. LVS简略介绍

    一.lvs是什么 LVS是 Linux Virtual Server 的简称,也就是Linux虚拟服务器.这是一个由章文嵩博士发起的一个开源项目,它的官方网站是 http://www.linuxvir ...

  5. RabbitMQ service does not start due to corrupted mnesia database in RSA Security Analytics

    rabbitmq异常:mnesia database损坏

  6. TensorFlow安装填坑之路(Windows环境)

    最近跟着简单粗暴 TensorFlow 2中的教学活动ML Study Jam 2020学习TensorFlow,记录下在Windows环境中安装TensorFlow时遇到的那些坑. TensorFl ...

  7. (3)这是一个简单的html页面,请保持为字符串,完成后面的计算要求。

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  8. [极客大挑战 2019]Http 1

    进入题目,可以看到是一个小型的网站 这里我也走了很多弯路,题目提示为HTTP,这里就可以在源码中找一些隐藏信息 搜搜.php可以看到有一个Secret.php 进入提示It doesn't come ...

  9. 痞子衡嵌入式:MCUBootUtility v2.3.1发布,解决了长久以来非空flash可能无法下载的问题

    -- 痞子衡维护的NXP-MCUBootUtility工具距离上一个版本(v2.3)发布过去3个月了,这一次痞子衡为大家带来了小版本升级v2.3.1(第一次做x.y.z中z级别更新),这个版本主要有两 ...

  10. MySQL学习(十)索引

    1.索引的种类 聚簇索引,非聚簇索引 主键索引,唯一索引,普通索引(前缀索引),全文索引 单值索引,复合索引 二级索引 覆盖索引 1.1 聚簇索引,非聚簇索引 参考文档: https://www.cn ...