Android-第一节基础知识及LinearLayout(线性布局)

<Button

android:id=“@+id/button2”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_weight=“1”

android:visibility=“gone” //gone 表示控件不可见,也不会占任何的位置,也不会有任何响应。

android:text=“button2”>

<Button

android:id=“@+id/button3”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_weight=“1”

android:text=“button3”>

效果如图:在这里插入图片描述

1.2控件的外边距


学习过HTML的都会知道CSS里的盒模式有个外边距和内边距。

外边距可以设置视图距离父视图上下左右的距离。

内边距可以设置视图内部内容距离自己边框上下左右的距离。

Android 的控件布局其实也用的是这个盒模式。

如果距离父视图上下左右的外边距相同,可以这么设置:

android:layout_margin=“10dp”

我们也可以单独的设置某个外边距:

android:layout_marginTop=“10dp”

android:layout_marginBottom=“10dp”

android:layout_marginLeft=“10dp”

android:layout_marginRight=“10dp”

1.3控件的内边距


统一设置上下左右内边距:

android:padding=“5dp”

各自设置内边距:

android:paddingTop=“5dp”

android:paddingBottom=“5dp”

android:paddingLeft=“5dp”

android:paddingRight=“5dp”

2.线性布局(Linear Layout)

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

LinearLayout 核心属性:

​ (1) android:orientation:两个属性值:“vertical” 垂直 “horizontal”水平

​ (2) android:layout_weight 将父控件的剩余空间按照设置的权重比例再分配

2.1示例:


在这里插入图片描述

<LinearLayout

android:id=“@+id/linearLayout”

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:orientation=“horizontal”

app:layout_constraintEnd_toEndOf=“parent”

app:layout_constraintStart_toStartOf=“parent”

app:layout_constraintTop_toTopOf=“parent”>

<Button

android:id=“@+id/button1”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“button1”>

<Button

android:id=“@+id/button2”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“button2”>

<Button

android:id=“@+id/button3”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“button3”>

2.2微信界面实战


在这里插入图片描述

<?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:orientation=“vertical”

android:layout_height=“match_parent”

tools:context=“.MainActivity”>

<TextView

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“×”

android:textSize=“50dp”

android:layout_marginLeft=“5dp”/>

<TextView

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginLeft=“20dp”

android:layout_marginTop=“5dp”

android:text=“微信号/QQ/邮箱登录”

android:textColor=“@color/black”

android:textSize=“30dp”/>

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:layout_marginTop=“30dp”>

<LinearLayout

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_weight=“1”

android:layout_marginTop=“6dp”

android:orientation=“horizontal”>

<TextView

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginLeft=“25dp”

android:text=“账号”

android:textColor=“@color/black”

android:textSize=“25dp” />

<LinearLayout

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_weight=“0”>

<EditText

android:layout_width=“wrap_content”

android:layout_height=“match_parent”

android:text="请填写微信号/QQ号/邮箱 "/>

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“45dp”

android:layout_marginTop=“10dp”

android:orientation=“horizontal”>

<LinearLayout

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_weight=“1”>

<TextView

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginLeft=“25dp”

android:text=“密码”

android:textColor=“@color/black”

android:textSize=“25dp” />

<LinearLayout

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_weight=“0”>

<EditText

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text="请填写密码 "/>

<TextView

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“用手机号登录”

android:layout_marginTop=“20dp”

android:layout_marginLeft=“25dp”

android:textSize=“20dp”

android:textColor=“@color/purple_500”/>

<Button

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:text=“登录”

android:textSize=“30dp”

android:layout_marginTop=“30dp”

/>

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:layout_marginTop=“150dp”

android:orientation=“horizontal”>

<LinearLayout

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_weight=“2”>

<TextView

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“找回密码”

android:layout_marginLeft=“80dp”

android:textColor=“@color/purple_500”
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。

img

img

img

img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)

总结

可以看出,笔者的工作学习模式便是由以下 「六个要点」 组成:

❝ 多层次的工作/学习计划 + 番茄工作法 + 定额工作法 + 批处理 + 多任务并行 + 图层工作法❞

希望大家能将这些要点融入自己的工作学习当中,我相信一定会工作与学习地更富有成效。

下面是我学习用到的一些书籍学习导图,以及系统的学习资料。每一个知识点,都有对应的导图,学习的资料,视频,面试题目。

**如:我需要学习 **Flutter的知识。(大家可以参考我的学习方法)

  • Flutter 的思维导图(无论学习什么,有学习路线都会事半功倍)

  • Flutter进阶学习全套手册

  • Flutter进阶学习全套视频

大概就上面这几个步骤,这样学习不仅高效,而且能系统的学习新的知识。

《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门即可获取!

❝ 多层次的工作/学习计划 + 番茄工作法 + 定额工作法 + 批处理 + 多任务并行 + 图层工作法❞

希望大家能将这些要点融入自己的工作学习当中,我相信一定会工作与学习地更富有成效。

下面是我学习用到的一些书籍学习导图,以及系统的学习资料。每一个知识点,都有对应的导图,学习的资料,视频,面试题目。

**如:我需要学习 **Flutter的知识。(大家可以参考我的学习方法)

  • Flutter 的思维导图(无论学习什么,有学习路线都会事半功倍)

[外链图片转存中…(img-lqhz4pKO-1712203086271)]

  • Flutter进阶学习全套手册

[外链图片转存中…(img-QId1Moq5-1712203086271)]

  • Flutter进阶学习全套视频

[外链图片转存中…(img-jOf3Tfhx-1712203086272)]

大概就上面这几个步骤,这样学习不仅高效,而且能系统的学习新的知识。

《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门即可获取!
  • 23
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值