Android-第一节基础知识及LinearLayout(线性布局),android实战开发教程

<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)

最后

针对于上面的问题,我总结出了互联网公司Android程序员面试涉及到的绝大部分面试题及答案,并整理做成了文档,以及系统的进阶学习视频资料。
(包括Java在Android开发中应用、APP框架知识体系、高级UI、全方位性能调优,NDK开发,音视频技术,人工智能技术,跨平台技术等技术资料),希望能帮助到你面试前的复习,且找到一个好的工作,也节省大家在网上搜索资料的时间来学习。
Android进阶视频+面试资料部分截图

《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!

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

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

最后

针对于上面的问题,我总结出了互联网公司Android程序员面试涉及到的绝大部分面试题及答案,并整理做成了文档,以及系统的进阶学习视频资料。
(包括Java在Android开发中应用、APP框架知识体系、高级UI、全方位性能调优,NDK开发,音视频技术,人工智能技术,跨平台技术等技术资料),希望能帮助到你面试前的复习,且找到一个好的工作,也节省大家在网上搜索资料的时间来学习。
[外链图片转存中…(img-tZ45QLCb-1712370778250)]

《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!

  • 8
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值