Android学习Day1

news2024/9/28 12:14:24

Android学习笔记

  • 了解Android 的结构
  • Activity
  • Android中的布局
  • 了解安卓的结构
  • Activity
  • Android中的布局
  • 代码展示(登录界面的实现):
  • 实现效果:
  • 代码展示(注册界面的实现)
  • 实现效果
  • 一些之前学习的笔记
  • end

了解Android 的结构

Activity

Android中的布局

了解安卓的结构

minSdkVersion:最小APIlevel

兼容设备的API不指定的话默认是1兼容所有设备,我们的设备低于API就不可以安装我们的APP

compieSdkVersion:编译的SDK版本

指定SDK去编译我们的版本,一般使用最新的去编译

targetSdkVersion:目标版本

匹配使用消除差异

dependencies:

依赖配置,依赖的库,定义其他的库

Activity

在这里插入图片描述

Android中的布局

相关的参数如下图:
在这里插入图片描述
在这里插入图片描述

代码展示(登录界面的实现):

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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">
    <!-- 头部背景 -->
    <ImageView
        android:id="@+id/hander"
        android:layout_width="match_parent"
        android:layout_height="280dp"
        android:contentDescription="@string/app_name"
        android:scaleType="centerCrop"
        android:src="@drawable/bg"
        app:layout_constraintTop_toTopOf="parent" />
<!--    <View-->
<!--        android:layout_width="0dp"-->
<!--        android:layout_height="0dp"-->
<!--        android:background="@drawable/hander_layer"-->
<!--        app:layout_constraintBottom_toBottomOf="@id/hander"-->
<!--        app:layout_constraintEnd_toEndOf="parent"-->
<!--        app:layout_constraintStart_toStartOf="parent"-->
<!--        app:layout_constraintTop_toTopOf="parent"/>-->

<View
    android:layout_width="1dp"
    android:layout_height="1dp"
    android:id="@+id/v1"
    android:layout_marginBottom="30dp"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintBottom_toBottomOf="@id/hander" />


    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@drawable/login_baground"
        android:paddingStart="30dp"
        android:paddingEnd="30dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/v1"
        app:layout_constraintVertical_bias="0.0"
        tools:layout_editor_absoluteX="1dp">

        <TextView
            android:id="@+id/welcome"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="10dp"
            android:layout_marginTop="25dp"
            android:layout_marginEnd="10dp"
            android:gravity="center"
            android:text="Welcome"
            android:textColor="@color/black"
            android:textSize="20sp"
            android:textStyle="bold"
            app:layout_constraintTop_toTopOf="parent" />

        <EditText
            android:id="@+id/inputEmail"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="10dp"
            android:layout_marginTop="40dp"
            android:layout_marginEnd="10dp"
            android:background="@null"
            android:hint="账户"
            android:imeOptions="actionNext"
            android:inputType="textEmailAddress"
            android:paddingStart="60dp"
            android:paddingEnd="10dp"
            android:textColor="@color/black"
            android:textSize="15sp"
            app:layout_constraintTop_toBottomOf="@+id/welcome"
            tools:ignore="Autofill" />

        <View
            android:id="@+id/view"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginStart="10dp"
            android:layout_marginTop="10dp"
            android:background="@color/black"
            app:layout_constraintTop_toBottomOf="@id/inputEmail" />

        <ImageView
            android:layout_width="20dp"
            android:layout_height="20sp"
            android:layout_marginStart="10dp"
            android:contentDescription="@string/app_name"
            android:src="@drawable/ic_email"
            app:layout_constraintBottom_toBottomOf="@id/inputEmail"
            app:layout_constraintStart_toStartOf="@id/inputEmail"
            app:tint="@color/cardview_shadow_start_color" />

        <EditText
            android:id="@+id/inputPassword"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="10dp"
            android:layout_marginTop="40dp"
            android:layout_marginEnd="10dp"
            android:background="@null"
            android:hint="密码"
            android:imeOptions="actionDone"
            android:inputType="textPassword"
            android:paddingStart="60dp"
            android:paddingEnd="10dp"
            android:textColor="@color/black"
            android:textSize="15sp"
            app:layout_constraintTop_toBottomOf="@id/view"
            tools:ignore="Autofill" />

        <View

            android:id="@+id/v2"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginStart="10dp"
            android:layout_marginTop="10dp"
            android:background="@color/black"
            app:layout_constraintTop_toBottomOf="@id/inputPassword" />

        <ImageView
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:layout_marginStart="10dp"
            android:contentDescription="@string/app_name"
            android:src="@drawable/ic_lock"
            app:layout_constraintBottom_toBottomOf="@id/inputPassword"
            app:layout_constraintStart_toStartOf="@id/inputPassword"
            app:tint="@color/cardview_shadow_start_color" />

        <Button
            android:id="@+id/btn1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="10dp"
            android:layout_marginTop="50dp"
            android:layout_marginEnd="10dp"
            android:background="@drawable/primary_button"
            android:text="@string/login"
            android:textAllCaps="false"
            android:textColor="@color/white"
            android:textSize="13sp"
            android:textStyle="bold"
            app:layout_constraintTop_toBottomOf="@id/v2" />

        <Button
            android:id="@+id/btn2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="10dp"
            android:layout_marginTop="30dp"
            android:layout_marginEnd="10dp"
            android:background="@drawable/primary_button"
            android:text="@string/Singup"
            android:textAllCaps="false"
            android:textColor="@color/white"
            android:textSize="13sp"
            android:textStyle="bold"
            app:layout_constraintTop_toBottomOf="@id/btn1" />


    </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

实现效果:

在这里插入图片描述

代码展示(注册界面的实现)

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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=".MainActivity2">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="260dp"
            android:scaleType="centerCrop"
            android:src="@drawable/bg"/>
    </LinearLayout>

    <LinearLayout
        android:layout_marginTop="30dp"
        android:layout_width="match_parent"
        android:gravity="center"
        android:padding="50dp"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <EditText
            android:id="@+id/name1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="账号:"/>
        <EditText
            android:id="@+id/pasw1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="密码:"/>
        <EditText
            android:id="@+id/nunber"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="手机号:"/>
        <EditText
            android:id="@+id/emmail"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="邮箱:"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <Button
                android:id="@+id/sumbit"
                android:layout_width="wrap_content"
                android:layout_weight="1"
                android:layout_marginTop="20dp"
                android:layout_marginRight="40dp"
                android:layout_height="wrap_content"
                android:text="提交"/>
            <Button
                android:id="@+id/back"
                android:layout_width="wrap_content"
                android:layout_marginTop="20dp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:text="返回"/>

        </LinearLayout>

    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

实现效果

在这里插入图片描述

一些之前学习的笔记

控件:
按钮
图片按钮
文本框
编辑框
照片框
图片
浏览器框
地图框
选择开关
图片开关

wrap_content 自适应

match_parent 充父控件

LinearLayout:线性布局

再设置id的时候id要保证唯一性
android:text=“确定”
android:orientation=“vertical” 设置布局方向 vertical 代表垂直
android:orientation=“horizontal” 设置布局方向 horizontal 代表 横向
android:gravity=“center” 设置布局方向 center 代表居中
android:layout_gravity=“center” 带layout是针对自己的方式
android:background=“@color/design_default_color_primary” 改变背景颜色

控件id是Java中文件与xml文件通讯的介质类似于控件的号码 必须唯一
按钮 实现单击事件
要实现控件是就必须与按钮的id进行绑定 且id必须唯一

java里面的函数

btn_1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

       }
   });

安卓开发要多调式 多刷程序 (因为不知道程序什么时候会崩掉)

Toast.makeText(MainActivity.this,“你好”,Toast.LENGTH_SHORT).show();
这个程序的意思是单击之后会有一个弹窗提示 ————————>你好。
—————
控件的联动
——
————
————————————————————————————————————————————————————————————————————————
EditText 这是一个编辑框
android:hint=“请输入名称” 文本框输入东西

LinearLayout 带LInear Layout就是针对自己的控件
android:layout_marginLeft=“140dp” 代表本身向左移动的空格
android:layout_marginTop=“20dp” 代表距离顶部的间距
要实现app之间的控件间距同理
android:layout_weight=“1” 控件实现均分
——————————————————————布局是嵌套进行的 一层套一层—————————————————————————----

************************************************************************
*                                                                       *
*        后期需要用到的东西按钮单击之后用来发送命令控制硬件   例如  open_door      *
*        文本框更新数据    用来接受硬件上报的传感器的值    例如 温度:36.5°C       *
*                                                                       *
*************************************************************************

举一反三很重要
需要网络权限  和授权

网络连接成功
订阅主题

MQTT是连接物联网的关键技术,因此这个协议很重要
UI之间反馈信息都靠这个

  • */

end

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/438361.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

服务(第八篇)location和rewrite

常用的Nginx正则表达式: 从功能看&#xff0c;rewrite和location似乎有点像&#xff0c;都能实现跳转&#xff0c;主要区别在于rewrite是在同一域名内更改获取资源的路径&#xff0c;而location是对一类路径做控制访问或反向代理&#xff0c;还可以proxy_pass到其他机器。 rew…

企业如何挑选设备管理系统?

在当今高度竞争的市场环境中&#xff0c;企业需要不断提高生产效率、确保设备的可靠性和安全性以降低运营成本。设备管理系统&#xff08;Equipment Management System&#xff0c;简称EMS&#xff09;是一种帮助企业实现这些目标的有力工具。本文将为您解析企业如何挑选合适的…

提高亚马逊等其他跨境平台的曝光率方法有哪些?

很多卖家都会想尽办法提高自己店铺的曝光率&#xff0c;但有些新手卖家可能不知道曝光率意味着什么 简单来说&#xff0c;曝光率是指你自己的店铺和产品被呈现给顾客的次数&#xff0c;一般来说&#xff0c;曝光率通常决定了你店铺的总流量&#xff0c;交易总量&#xff0c;订…

PM866 3BSE050200R1高压变频器的四种控制方法

PM866 3BSE050200R1高压变频器的四种控制方法 高压变频器装置指驱动输入电源为6&#xff0c;000V或10KV的电机装置&#xff0c;高压变频器一般主要有下列几种方案选择&#xff1a; 一、直接高压控制&#xff08;高成本&#xff09; 目前以采用美国罗宾康类似的无谐波变频技术&a…

凌恩生物美文分享|3月客户文章盘点——累计IF=105,平均IF=8.08

凌恩生物以打造国内一流生物公司为目标&#xff0c;在科研测序领域深耕不辍&#xff0c;吸纳多名在生物信息高级技术人员的加盟&#xff0c;参与并完成多个高科技项目。现已在宏组学、基因组、表观遗传以及蛋白代谢等多组学及联合分析领域积累了深厚经验&#xff0c;打造出成熟…

ASP.NET Core MVC 从入门到精通之布局

随着技术的发展&#xff0c;ASP.NET Core MVC也推出了好长时间&#xff0c;经过不断的版本更新迭代&#xff0c;已经越来越完善&#xff0c;本系列文章主要讲解ASP.NET Core MVC开发B/S系统过程中所涉及到的相关内容&#xff0c;适用于初学者&#xff0c;在校毕业生&#xff0c…

核心业务4:标的管理

核心业务4:标的管理 1.标的管理流程图 2.数据库表设计 3.前端逻辑设计 4.后端逻辑设计 5.标的放款TODO 核心业务4:标的管理 1.标的管理流程图 ①上一个核心业务通过审核借款申请结束

mybatis-plus的代码生成器的应用

目录 1.工程引入mybatis-plus3-generator代码生成器2.只需要关注mybatis-plus-config.properties然后生成代码3.分别添加依赖解决报错4.加入其它配置然后测试效果 3.4版本 1.工程引入mybatis-plus3-generator代码生成器 mybatis-plus3-generator放入项目工程中&#xff0c;父工…

JeecgBoot 3.5.1 版本发布,开源的企业级低代码平台

项目介绍 JeecgBoot是一款企业级的低代码平台&#xff01;前后端分离架构 SpringBoot2.x&#xff0c;SpringCloud&#xff0c;Ant Design&Vue3&#xff0c;Mybatis-plus&#xff0c;Shiro&#xff0c;JWT 支持微服务。强大的代码生成器让前后端代码一键生成! JeecgBoot引领…

kafka manager服务部署

1.配置一台centos7主机或者直接在kafka服务主机上部署也可以&#xff0c;关闭firewalld和selinux服务 2.安装java环境(需要jdk11以上) 参考&#xff1a;jdk1.8环境配置_Apex Predator的博客-CSDN博客 3.从github上下载编译好的cmak压缩包(下载最新版本的3.0.0.6) 下载地址&a…

Gradio 部署工具保姆级教程来了,以图生图,画你所想

2023 年以来国内各家大厂竞相发布大模型&#xff0c;AIGC 的热度来到了前所未有的高度&#xff0c;AI 绘画在国际艺术博览会上频频夺冠&#xff0c;数字艺术的新纪元正在逐渐展开。你是否也想与顶尖技术人员一起&#xff0c;参与到 AIGC 的浪潮中呢&#xff1f; 2023 PaddlePa…

source insight4.0使用技巧总结

一、技巧1&#xff1a;查看函数调用关系 步骤 1&#xff1a;在主菜单中点击下图中的按钮 图 1 打开relation界面 步骤 2&#xff1a;在弹出的relation界面点击“设置”按钮&#xff0c; 图2 点击“设置”按钮 步骤3&#xff1a; 在“设置”界面中&#xff0c;“Levels”选择…

一文详解一致性协议

目录 一致性协议 2PC二阶段提交 二阶段提交存在的问题&#xff1a; 3PC 三阶段提交 优点 Paxos算法 流程演变 Paxos优缺点 活锁问题 ZAB协议(Fast Paxos) 一致性协议 事务需要跨多个分布式节点时&#xff0c;为了保证事务的ACID特性&#xff0c;需要选举出一个协调者…

LeetCode 1105. Filling Bookcase Shelves【记忆化搜索,动态规划】中等

本文属于「征服LeetCode」系列文章之一&#xff0c;这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁&#xff0c;本系列将至少持续到刷完所有无锁题之日为止&#xff1b;由于LeetCode还在不断地创建新题&#xff0c;本系列的终止日期可能是永远。在这一系列刷题文章…

甘特图控件DHTMLX Gantt入门使用教程【引入】:dhtmlxGantt与ASP.NET Core(下)

DHTMLX Gantt 是用于跨浏览器和跨平台应用程序的功能齐全的Gantt图表。可满足项目管理应用程序的大部分开发需求&#xff0c;具备完善的甘特图图表库&#xff0c;功能强大&#xff0c;价格便宜&#xff0c;提供丰富而灵活的JavaScript API接口&#xff0c;与各种服务器端技术&a…

从Pandas快速切换到Polars :数据的ETL和查询

对于我们日常的数据清理、预处理和分析方面的大多数任务&#xff0c;Pandas已经绰绰有余。但是当数据量变得非常大时&#xff0c;它的性能开始下降。 我们以前的两篇文章来测试Pandas 1.5.3、polar和Pandas 2.0.0之间的性能了&#xff0c;Polars 正好可以解决大数据量是处理的…

电影《忠犬八公》观后感

上周看了电影《忠犬八公》&#xff0c;整部电影是以一条狗为故事线演绎的&#xff0c;之前看电影《忠犬帕尔玛》的时候&#xff0c;同事就推荐了《忠犬八公》&#xff0c;以为说的是同一部电影&#xff0c;去维基百科查过才知道&#xff0c;中国版的冯小刚为主演的《忠犬八公》…

全景丨0基础学习VR全景制作,平台篇第五章:开场封面功能

大家好欢迎观看蛙色平台使用教程 开场封面功能&#xff0c;现已支持开场图片和开场视频两种呈现方式&#xff0c; 分别针对PC端和移动设备访问分别设置呈现图片、视频内容&#xff0c;满足市场主流需求。 开场图片 传达主旨 1、全局-开场封面-图片 2、分别对PC端和移动设备访…

手动构建自己的docker容器镜像实战

前言 之前的实战中&#xff0c;我们实战中&#xff0c;我们使用的镜像都是镜像仓库已有的镜像。 已有的镜像都是别人已经开发好上传的。今天我们一起来看看如何构建自己的镜像并上传到镜像仓库中。 &#x1f3e0;个人主页&#xff1a;我是沐风晓月 &#x1f9d1;个人简介&…

[计算机图形学]光线追踪前瞻:阴影图(前瞻预习/复习回顾)

一、前言 我们前面学习过了光栅化&#xff0c;而光栅化会有一系列问题&#xff0c;比如&#xff1a;全局的光线传输&#xff0c;阴影。我们之前讲着色的时候说了&#xff0c;我们认为着色是一个局部的操作&#xff0c;我们只考虑着色点本身&#xff0c;并不考虑其它物体的遮挡对…