Android学习登录页面 - 第一天

背景:已学习Java基础知识及高级部门,具有一定java基础知识。

一、熟悉Android项目结构

参考链接:Android 项目的基本结构

1. gradle目录下是 Android Studio 自动创建的一些文件

参考链接:Android-Gradle详解

参考链接:Android --- Gradle是什么?

二、创建Android测试项目

1.描述:实现登录页面功能:用户名、用户密码、登录按钮。

2.Android创建项目

参考链接:Android教程之如何创建一个新的 Android 项目_知识大胖的博客-CSDN博客_新建一个android

实现登录页面:

第一步:在app/res/layout/fragment_home.xml中实现登录页面

a. UI自上而下使用线性垂直布局,点击linearLayout(vertical)拖拽到试图中或手动敲代码也可以。

 b.拖拽对应的文本、输入框、按钮等到布局中,调整样式使得页面布局样式能好看一点。

 写页面的时候对于样式布局存在困惑或不知道怎么排版是难点?

解决方案: 前期手动敲代码实现页面,不依赖于UI design功能,加深记忆和深入思考。

备注:写页面主要难点是页面排版,可参考链接:Android常见页面布局_飞芜的博客-CSDN博客_android页面布局

附登录页面代码: ****手动敲的代码****

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:orientation="vertical"
    tools:context=".ui.home.HomeFragment">

    <TextView
        android:id="@+id/textView"
        android:layout_marginTop="50dp"
        android:layout_gravity="center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="登录"
        android:textStyle="bold"
        android:textColor="@color/design_default_color_primary"
        android:textSize="40sp"/>
    <LinearLayout
        android:id="@+id/l_account"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="50sp"
        android:layout_marginRight="50sp"
        android:orientation="horizontal">
        <ImageView
            android:src="@drawable/ic_dashboard_black_24dp"
            android:layout_width="32dp"
            android:layout_height="32dp"
            android:scaleType="fitCenter"
            android:layout_gravity="center"/>
        <EditText
            android:id="@+id/account"
            android:textSize="18sp"
            android:textStyle="normal"
            android:textAllCaps="false"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:hint="账号"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/l_password"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="50sp"
        android:layout_marginRight="50sp"
        android:orientation="horizontal">
        <ImageView
            android:src="@drawable/ic_dashboard_black_24dp"
            android:layout_width="32dp"
            android:layout_height="32dp"
            android:scaleType="fitCenter"
            android:layout_gravity="center"/>
        <EditText
            android:id="@+id/password"
            android:textSize="18sp"
            android:textStyle="normal"
            android:textAllCaps="false"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:hint="密码"/>
    </LinearLayout>
    <Button
        android:id="@+id/login"
        android:text="登录"
        android:textSize="20sp"
        android:layout_width="match_parent"
        android:layout_height="50sp"
        android:layout_marginRight="50sp"
        android:layout_marginLeft="50sp"
        android:layout_marginTop="20sp"
        />
</LinearLayout>

三、调试

1.虚拟机调试安装:

参考链接:Android Studio连接真机教程(超详细) - 灰信网(软件开发博客聚合)

2.真机调试安装

参考链接:荣耀开发者选项在哪 - 万年历

参考链接:https://jingyan.baidu.com/article/ca41422fce01335faf99ed35.html

QA:真机联调提示“报签名不一致,该应可能已被篡改”问题?

参考链接:华为手机通过adb安装APK提示“签名不一致,该应用可能已被修改”_喜欢踢足球的老罗的博客-CSDN博客_签名不一致该应用可能被修改

真机调试效果:

 QA:

1. Android页面加载逻辑及底层实现原理?

2.页面事件注册及校验逻辑?

3.感觉页面实现有点low,有没有关于android UI组件库。

依赖问题将在下一节课进行解决,因上班只能用业务时间来解决了。希望自己可以坚持下去

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值