JetpackCompose从入门到实战学习笔记8—ConstraintLayout的简单使用

news2024/9/29 0:55:20

JetpackCompose从入门到实战学习笔记8—ConstraintLayout的简单使用

1.简介:

Compose 中的 ConstraintLayout

ConstraintLayout 是一种布局,让您可以相对于屏幕上的其他可组合项来放置可组合项。它是一种实用的替代方案,可代替使用多个已嵌套的 RowColumnBox 和其他自定义布局元素这种做法。在实现对齐要求比较复杂的较大布局时,ConstraintLayout 很有用。

在以下情况下,考虑使用 ConstraintLayout

  • 为了避免在屏幕上定位元素时嵌套多个 ColumnRow,以便提高代码的可读性。
  • 相对于其它可组合项来定位可组合项,或根据引导线、屏障线或链来定位可组合项。

在 View 系统中,建议使用 ConstraintLayout 来创建复杂的大型布局,因为扁平视图层次结构比嵌套视图的效果更好。不过,这在 Compose 中不是什么问题,因为 Compose 能够高效地处理较深的布局层次结构。

2.在build.gradle中添加依赖:

    implementation "androidx.constraintlayout:constraintlayout-compose:1.0.1"

3.可组合项简单使用:

@Composable
fun ConstraintLayoutContent() {
    ConstraintLayout {
        // Create references for the composables to constrain
        val (button, text) = createRefs()
        Button(
            onClick = { /* Do something */ },
            // Assign reference "button" to the Button composable
            // and constrain it to the top of the ConstraintLayout
            modifier = Modifier.constrainAs(button) {
                top.linkTo(parent.top, margin = 16.dp)
            }
        ) {
            Text("Button")
        }

        // Assign reference "text" to the Text composable
        // and constrain it to the bottom of the Button composable
        Text("Android", Modifier.constrainAs(text) {
            top.linkTo(button.bottom, margin = 16.dp)
        })
    }
}

4.效果如下:

在这里插入图片描述

5.Barrier分界线:

    @Preview
    @Composable
    fun InputFieldLayoutDemo() {
        ConstraintLayout(
            modifier = Modifier
                .width(400.dp)
                .height(100.dp)
                .padding(10.dp)
        ) {
            val (usernameTextRef, passwordTextRef, usernameInputRef, passWordInputRef, dividerRef) = remember { createRefs() }
            var barrier = createEndBarrier(usernameTextRef, passwordTextRef)
            Text(
                text = "用户名",
                fontSize = 14.sp,
                textAlign = TextAlign.Left,
                modifier = Modifier
                    .constrainAs(usernameTextRef) {
                        top.linkTo(parent.top)
                        start.linkTo(parent.start)
                    }
            )
            Divider(
                Modifier
                    .fillMaxWidth()
                    .constrainAs(dividerRef) {
                        top.linkTo(usernameTextRef.bottom)
                        bottom.linkTo(passwordTextRef.top)
                    })
            Text(
                text = "密码",
                fontSize = 14.sp,
                modifier = Modifier
                    .constrainAs(passwordTextRef) {
                        top.linkTo(usernameTextRef.bottom, 19.dp)
                        start.linkTo(parent.start)
                    }
            )
            OutlinedTextField(
                value = "",
                onValueChange = {},
                modifier = Modifier.constrainAs(usernameInputRef) {
                    start.linkTo(barrier, 10.dp)
                    top.linkTo(usernameTextRef.top)
                    bottom.linkTo(usernameTextRef.bottom)
                    height = Dimension.fillToConstraints
                }
            )
            OutlinedTextField(
                value = "",
                onValueChange = {},
                modifier = Modifier.constrainAs(passWordInputRef) {
                    start.linkTo(barrier, 10.dp)
                    top.linkTo(passwordTextRef.top)
                    bottom.linkTo(passwordTextRef.bottom)
                    height = Dimension.fillToConstraints
                }
            )
        }
    }

6.效果如下:

在这里插入图片描述

7.GuideLine引导线:

    @Preview
    @Composable
    fun GuidelineSample(){
            ConstraintLayout(
                modifier = Modifier
                    .fillMaxSize()
                    .padding(10.dp)
                    .background(Color.White)
            ) {
                val topGuideline = createGuidelineFromTop(0.2f)
                var (userPortraitBackgroundRef, userPortraitImgRef, welcomeRef, quotesRef) = remember { createRefs() }
                Box(
                    modifier = Modifier
                        .background(Color.Green)
                        .constrainAs(userPortraitBackgroundRef) {
                            top.linkTo(parent.top)
                            bottom.linkTo(topGuideline)
                            height = Dimension.fillToConstraints
                            width = Dimension.matchParent
                        }
                )
                Image(
                    painter = painterResource(id = R.mipmap.avatar),
                    contentDescription = stringResource(R.string.description),
                    contentScale = ContentScale.Crop,
                    modifier = Modifier
                        .constrainAs(userPortraitImgRef)
                        {
                            top.linkTo(topGuideline)
                            bottom.linkTo(topGuideline)
                            start.linkTo(parent.start)
                            end.linkTo(parent.end)
                        }
                        .size(100.dp)
                        .clip(CircleShape)
                        .border(width = 2.dp, color = Color.Red, shape = CircleShape)
                )
                Text(text = "Compose 技术爱好者Compose 技术爱好者Compose 技术爱好者Compose 技术爱好者Compose 技术爱好者Compose ",
                    fontSize = 24.sp,
                    maxLines = 1,
                    textAlign = TextAlign.Center,
                    overflow = TextOverflow.Ellipsis,//1行显示不下时是否显示。。。
                    modifier = Modifier.constrainAs(welcomeRef) {
                        top.linkTo(userPortraitImgRef.bottom, 30.dp)
                        start.linkTo(parent.start)
                        end.linkTo(parent.end)
                        width = Dimension.preferredWrapContent
                    }
                )
            }
    }

//这里有个小技巧:若要想TextView一行铺满但没有完全显示且显示。。。时设置 overflow = TextOverflow.Ellipsis属性

8.效果如下:

在这里插入图片描述

9.Chain链接约束:

 /**
     *  Chain链接约束,Compose提供了ChainStyle
     *  1.Spread:链条中美国元素均分整个parent空间。
     *  2.SpreadInside:链条中首尾元素紧贴边界,剩下每个元素平分整个parent空间。
     *  3.Packed:链条在所有元素聚焦到中间。
     */
    @Preview
    @Composable
    fun ChainDemo() {
        ConstraintLayout(
            modifier = Modifier
                .fillMaxSize()
                .background(Color.Gray)
        ) {
            val (quotesFirstLineRef, quotesSecondLineRef, quotesThirdLineRef, quotesForthLineRef) = remember { createRefs() }
            createVerticalChain(quotesFirstLineRef, quotesSecondLineRef, quotesThirdLineRef, quotesForthLineRef,
                chainStyle = ChainStyle.SpreadInside)
            Text(
                text = "寄蜉蝣于天地,",
                color = Color.White,
                fontSize = 30.sp,
                fontWeight = FontWeight.Bold,
                modifier = Modifier.constrainAs(quotesFirstLineRef) {
                    start.linkTo(parent.start)
                    end.linkTo(parent.end)
                }
            )
            Text(
                text = "渺沧海之一粟。",
                color = Color.White,
                fontSize = 30.sp,
                fontWeight = FontWeight.Bold,
                modifier = Modifier.constrainAs(quotesSecondLineRef) {
                    start.linkTo(parent.start)
                    end.linkTo(parent.end)
                }
            )

            Text(
                text = "哀吾生之须臾,",
                color = Color.White,
                fontSize = 30.sp,
                fontWeight = FontWeight.Bold,
                modifier = Modifier.constrainAs(quotesThirdLineRef) {
                    start.linkTo(parent.start)
                    end.linkTo(parent.end)
                }
            )
            Text(
                text = "羡长江之无穷。",
                color = Color.White,
                fontSize = 30.sp,
                fontWeight = FontWeight.Bold,
                modifier = Modifier.constrainAs(quotesForthLineRef) {
                    start.linkTo(parent.start)
                    end.linkTo(parent.end)
                }
            )
        }
    }

10.Spread模式效果如下:

  • Spread模式:链条中美国元素均分整个parent空间。

在这里插入图片描述

11.SpreadInside模式效果如下:

  • SpreadInside:链条中首尾元素紧贴边界,剩下每个元素平分整个parent空间。

在这里插入图片描述

12.Packed模式效果如下:

  • Packed:链条在所有元素聚焦到中间。

在这里插入图片描述

13.完整代码如下:

import android.os.Bundle
import android.widget.ScrollView
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.constraintlayout.compose.ChainStyle
import androidx.constraintlayout.compose.ConstraintLayout
import androidx.constraintlayout.compose.Dimension

/**
 * @auth: njb
 * @date: 2023/1/17 16:36
 * @desc:
 */
class ConstraintLayoutActivity:ComponentActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
           // ConstraintLayoutContent()
           // ConstraintLayoutSample()
            //InputFieldLayoutDemo()
            //GuidelineSample()
            ChainDemo()
        }
    }

    @Preview
    @Composable
    fun ConstraintLayoutContent() {
        ConstraintLayout {
            // Create references for the composables to constrain
            val (button, text) = createRefs()
            Button(
                onClick = { /* Do something */ },
                // Assign reference "button" to the Button composable
                // and constrain it to the top of the ConstraintLayout
                modifier = Modifier.constrainAs(button) {
                    top.linkTo(parent.top, margin = 16.dp)
                }
            ) {
                Text("Button")
            }

            // Assign reference "text" to the Text composable
            // and constrain it to the bottom of the Button composable
            Text("Android", Modifier.constrainAs(text) {
                top.linkTo(button.bottom, margin = 16.dp)
            })
        }
    }

    @Preview
    @Composable
    fun  ConstraintLayoutSample(){
            ConstraintLayout(
                modifier = Modifier
                    .width(400.dp)
                    .height(300.dp)
                    .padding(10.dp)
            ) {
                // Create references for the composables to constrain
                val (button, text) = createRefs()
                Button(
                    onClick = { },
                    // Assign reference "button" to the Button composable
                    // and constrain it to the top of the ConstraintLayout
                    modifier = Modifier.constrainAs(button) {
                        top.linkTo(parent.top, margin = 6.dp)
                    }
                ) {
                    Text("Button")
                }

                // Assign reference "text" to the Text composable
                // and constrain it to the bottom of the Button composable
                Text("Android", Modifier.constrainAs(text) {
                    top.linkTo(button.bottom, margin = 6.dp)
                })
                val (portraitImageRef, usernameTextRef, desTextRef) = remember { createRefs() }
                Image(
                    painter = painterResource(id = R.mipmap.avatar),
                    contentDescription = stringResource(R.string.description),
                    contentScale = ContentScale.Crop,
                    modifier = Modifier
                        .constrainAs(portraitImageRef)
                        {
                            top.linkTo(parent.top)
                            bottom.linkTo(parent.bottom)
                        }
                        .size(100.dp))
                Text(text = "Compose 技术爱好者Compose 技术爱好者Compose 技术爱好者Compose 技术爱好者Compose 技术爱好者Compose ",
                    fontSize = 14.sp,
                    maxLines = 1,
                    textAlign = TextAlign.Center,
                    overflow = TextOverflow.Ellipsis,//1行显示不下时是否显示。。。
                    modifier = Modifier.constrainAs(usernameTextRef) {
                        top.linkTo(portraitImageRef.top)
                        start.linkTo(portraitImageRef.end, 10.dp)
                        end.linkTo(parent.end, 10.dp)
                        width = Dimension.preferredWrapContent
                    })
                Text(text = "我的个人描述...",
                    fontSize = 14.sp,
                    color = Color.Red,
                    fontWeight = FontWeight.Light,
                    modifier = Modifier.constrainAs(desTextRef) {
                        top.linkTo(usernameTextRef.bottom, 5.dp)
                        start.linkTo(portraitImageRef.end, 10.dp)
                    }
                )
        }
    }

    @Preview
    @Composable
    fun GuidelineSample(){
            ConstraintLayout(
                modifier = Modifier
                    .fillMaxSize()
                    .padding(10.dp)
                    .background(Color.White)
            ) {
                val topGuideline = createGuidelineFromTop(0.2f)
                var (userPortraitBackgroundRef, userPortraitImgRef, welcomeRef, quotesRef) = remember { createRefs() }
                Box(
                    modifier = Modifier
                        .background(Color.Green)
                        .constrainAs(userPortraitBackgroundRef) {
                            top.linkTo(parent.top)
                            bottom.linkTo(topGuideline)
                            height = Dimension.fillToConstraints
                            width = Dimension.matchParent
                        }
                )
                Image(
                    painter = painterResource(id = R.mipmap.avatar),
                    contentDescription = stringResource(R.string.description),
                    contentScale = ContentScale.Crop,
                    modifier = Modifier
                        .constrainAs(userPortraitImgRef)
                        {
                            top.linkTo(topGuideline)
                            bottom.linkTo(topGuideline)
                            start.linkTo(parent.start)
                            end.linkTo(parent.end)
                        }
                        .size(100.dp)
                        .clip(CircleShape)
                        .border(width = 2.dp, color = Color.Red, shape = CircleShape)
                )
                Text(text = "Compose 技术爱好者Compose 技术爱好者Compose 技术爱好者Compose 技术爱好者Compose 技术爱好者Compose ",
                    fontSize = 24.sp,
                    maxLines = 1,
                    textAlign = TextAlign.Center,
                    overflow = TextOverflow.Ellipsis,//1行显示不下时是否显示。。。
                    modifier = Modifier.constrainAs(welcomeRef) {
                        top.linkTo(userPortraitImgRef.bottom, 30.dp)
                        start.linkTo(parent.start)
                        end.linkTo(parent.end)
                        width = Dimension.preferredWrapContent
                    }
                )
            }
    }

    @Preview
    @Composable
    fun InputFieldLayoutDemo() {
        ConstraintLayout(
            modifier = Modifier
                .width(400.dp)
                .height(100.dp)
                .padding(10.dp)
        ) {
            val (usernameTextRef, passwordTextRef, usernameInputRef, passWordInputRef, dividerRef) = remember { createRefs() }
            var barrier = createEndBarrier(usernameTextRef, passwordTextRef)
            Text(
                text = "用户名",
                fontSize = 14.sp,
                textAlign = TextAlign.Left,
                modifier = Modifier
                    .constrainAs(usernameTextRef) {
                        top.linkTo(parent.top)
                        start.linkTo(parent.start)
                    }
            )
            Divider(
                Modifier
                    .fillMaxWidth()
                    .constrainAs(dividerRef) {
                        top.linkTo(usernameTextRef.bottom)
                        bottom.linkTo(passwordTextRef.top)
                    })
            Text(
                text = "密码",
                fontSize = 14.sp,
                modifier = Modifier
                    .constrainAs(passwordTextRef) {
                        top.linkTo(usernameTextRef.bottom, 19.dp)
                        start.linkTo(parent.start)
                    }
            )
            OutlinedTextField(
                value = "",
                onValueChange = {},
                modifier = Modifier.constrainAs(usernameInputRef) {
                    start.linkTo(barrier, 10.dp)
                    top.linkTo(usernameTextRef.top)
                    bottom.linkTo(usernameTextRef.bottom)
                    height = Dimension.fillToConstraints
                }
            )
            OutlinedTextField(
                value = "",
                onValueChange = {},
                modifier = Modifier.constrainAs(passWordInputRef) {
                    start.linkTo(barrier, 10.dp)
                    top.linkTo(passwordTextRef.top)
                    bottom.linkTo(passwordTextRef.bottom)
                    height = Dimension.fillToConstraints
                }
            )
        }
    }


    /**
     *  Chain链接约束,Compose提供了ChainStyle
     *  1.Spread:链条中美国元素均分整个parent空间
     *  2.SpreadInside:
     *  3.Packed:
     */
    @Preview
    @Composable
    fun ChainDemo() {
        ConstraintLayout(
            modifier = Modifier
                .fillMaxSize()
                .background(Color.Gray)
        ) {
            val (quotesFirstLineRef, quotesSecondLineRef, quotesThirdLineRef, quotesForthLineRef) = remember { createRefs() }
            createVerticalChain(quotesFirstLineRef, quotesSecondLineRef, quotesThirdLineRef, quotesForthLineRef,
                chainStyle = ChainStyle.Packed)
            Text(
                text = "寄蜉蝣于天地,",
                color = Color.White,
                fontSize = 30.sp,
                fontWeight = FontWeight.Bold,
                modifier = Modifier.constrainAs(quotesFirstLineRef) {
                    start.linkTo(parent.start)
                    end.linkTo(parent.end)
                }
            )
            Text(
                text = "渺沧海之一粟。",
                color = Color.White,
                fontSize = 30.sp,
                fontWeight = FontWeight.Bold,
                modifier = Modifier.constrainAs(quotesSecondLineRef) {
                    start.linkTo(parent.start)
                    end.linkTo(parent.end)
                }
            )

            Text(
                text = "哀吾生之须臾,",
                color = Color.White,
                fontSize = 30.sp,
                fontWeight = FontWeight.Bold,
                modifier = Modifier.constrainAs(quotesThirdLineRef) {
                    start.linkTo(parent.start)
                    end.linkTo(parent.end)
                }
            )
            Text(
                text = "羡长江之无穷。",
                color = Color.White,
                fontSize = 30.sp,
                fontWeight = FontWeight.Bold,
                modifier = Modifier.constrainAs(quotesForthLineRef) {
                    start.linkTo(parent.start)
                    end.linkTo(parent.end)
                }
            )
        }
    }
}

14.完整效果预览如下:

在这里插入图片描述

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

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

相关文章

JVM垃圾回收机制GC理解

目录JVM垃圾回收分代收集如何识别垃圾引用计数法可达性分析法引用关系四种类型: 强、软、弱、虚强引用软引用 SoftReference弱引用 WeakReferenceWeakHashMap软引用与虚引用的使用场景虚引用与引用队列引用队列虚引用 PhantomReference垃圾回收算法引用计数复制 Cop…

06- 梯度下降(SGDRegressor) (机器学习)

梯度下降算法也是先构建误差值的函数, 通过求误差值函数的最小值来达到误差最小的目的, 不过梯度下降是先随机取值, 然后求函数在该点的导数, 如果导数为正, 下一次取值向反方向移动, 如果导数为负, 正向移动, 直到导数取值极小时, 认定误差达到一个可以接受的范围, 然后导出相…

解读手机拍照的各个参数(拍照时,上面会有6个符号)

1第一个符号是闪光灯符号,如下图所示。有四种模式, 手机的闪光灯分别为关闭、自动、开启和常亮四种状态。 关闭:就是在任何情况下都不会闪光 自动:由手机来判断此时的光线强弱,若手机测光认为光线太弱,则…

前端限制 git commit 提交格式

团队开发中,每个人 git commit 的习惯都不一样,这样不利于对更新日志的筛选,也可以防止同事跑路后,出现 bug 后,看不懂他当时提交的日志究竟是改了个 bug 还是新增了一个功能,影响开发效率。 这时候就需要…

springboot驾校报名系统 微信小程序

系统分为用户和管理员,驾校教练三个角色 用户微信小程序端的主要功能有: 1.用户注册和登陆系统 2.用户查看驾校教练信息 3.用户查看驾校信息 4.用户查看驾校的车辆信息 5.用户查看驾校考试信息,在线报名考试 6.用户可以在线预约驾校的教练 7.…

深度学习笔记--修改、增加和删除预训练模型的特定层

目录 1--前言 2--初始化 VGG16 模型 3--修改特定层 4--新增特定层 5--删除特定层 6--固定预训练模型的权重 7--综合应用 1--前言 基于 Pytorch,以 VGG16 模型为例; 2--初始化 VGG16 模型 from torchvision import models# 初始化模型 vgg16 mo…

Java 反射详解

一、反射 1、什么是反射 反射允许对成员变量、成员方法和构造器的信息进行编程访问。 补充:暴力反射,非public修饰需要打开权限 setAccessible(boolean) 2、反射的作用 利用反射创建的对象可以无视修饰符调用类里面的内容可以跟配置文件结合起来使用,把要创建的对象…

【Jest】Jest单元测试环境搭建

文章目录前言1、项目环境搭建初始化仓库安装ts环境安装jest环境2、初始化项目文件夹前言 今天开始!!!学习vue源码,那么要学习源码前首先要了解Jest。 https://www.jestjs.cn/ 官网自带中文非常友好! 1、项目环境搭建…

【C++面试问答】搞清楚深拷贝与浅拷贝的区别

问题 深拷贝和浅拷贝的区别是面试中的常见问题之一,对于不同的编程语言,这个问题的回答可能稍有差别,下面我们就来探索一下它们之间的异同吧。 先来看看在JavaScript对象的深拷贝与浅拷贝的区别: 浅拷贝:只是复制了…

Postgresql 根据单列或几列分组去重row_number() over() partition by

Postgresql 根据单列或几列分组去重row_number() over() partition by 一般用于单列或者几列需要去重后进行计算值的 count(distinct(eid)) 可以 比如有个例子,需要根据名称,城市去筛选覆盖的道路长度,以月因为建立了唯一索引是ok的&#…

前端项目集成Vite配置一览无余

Vite配置文件 默认指定&#xff1a;vite.config.js。自定义指定&#xff1a;vite --config 自定义名称.js。 Vite相关命令 查看Vite有哪些命令&#xff1a;npx vite -help。 --host [host]// 指定域名 --port <port>// 指定端口 --https // 使用 TLSHTTP/2 --cors //…

Spring 中 ApplicationContext 和 BeanFactory 的区别

文章目录类图包目录不同国际化强大的事件机制&#xff08;Event&#xff09;底层资源的访问延迟加载常用容器类图 包目录不同 spring-beans.jar 中 org.springframework.beans.factory.BeanFactoryspring-context.jar 中 org.springframework.context.ApplicationContext 国际…

HTTP 和 HTTPS 的区别

文章目录前言一、HTTP 与 HTTPS 的基本概念HTTPHTTPS二、HTTP 和 HTTPS协议的区别前言 浏览网站时&#xff0c;我们会发现网址有两种格式&#xff0c;一种以http://开头&#xff0c;一种https://开头。好像这两种格式差别不大&#xff0c;只多了一个s&#xff0c;实际上他们有…

Java零基础教程——数组

目录数组静态初始化数组数组的访问数组的动态初始化元素默认值规则&#xff1a;数组的遍历数组遍历-求和冒泡排序数组的逆序交换数组 数组就是用来存储一批同种类型数据的容器。 20, 10, 80, 60, 90 int[] arr {20, 10, 80, 60, 90}; //位置 0 1 2 3 4数组的…

死锁的原因及解决方法

❣️关注专栏&#xff1a; JavaEE 死锁☘️1.什么是死锁☘️2.死锁的三个典型情况☘️2.1情况一☘️2.2情况二☘️2.2.1死锁的代码展示☘️2.3多个线程多把锁☘️3死锁产生的必要条件☘️3.1互斥性☘️3.2不可抢占☘️3.3请求和保持☘️3.4循环等待☘️4如何避免死锁☘️4.1避免…

【Spark分布式内存计算框架——Spark Core】6. RDD 持久化

3.6 RDD 持久化 在实际开发中某些RDD的计算或转换可能会比较耗费时间&#xff0c;如果这些RDD后续还会频繁的被使用到&#xff0c;那么可以将这些RDD进行持久化/缓存&#xff0c;这样下次再使用到的时候就不用再重新计算了&#xff0c;提高了程序运行的效率。 缓存函数 可以…

Kubernetes集群-部署Java项目

Kubernetes集群-部署Java项目&#xff08;SSG&#xff09; k8s部署项目java流程图 第一步 打包制作镜像 打包 java源码&#xff1a; application.properties #在有pom.xml的路径下执行 mvn clean package制作镜像&#xff1a; 将刚才打包后的文件夹传到&#xff0c;装有dock…

(考研湖科大教书匠计算机网络)第三章数据链路层-第十一节:虚拟局域网VLAN概述和实现机制

获取pdf&#xff1a;密码7281专栏目录首页&#xff1a;【专栏必读】考研湖科大教书匠计算机网络笔记导航 文章目录一&#xff1a;VLAN概述&#xff08;1&#xff09;分割广播域&#xff08;2&#xff09;虚拟局域网VLAN二&#xff1a;VLAN实现机制&#xff08;1&#xff09;IEE…

LeetCode题目笔记——15. 三数之和

文章目录题目描述题目链接题目难度——中等方法一&#xff1a;暴力&#xff08;参考&#xff09;代码/Python 参考方法二&#xff1a;哈希代码/Python参考方法三&#xff1a;排序双指针代码/Python代码/C总结题目描述 龙门阵&#xff1a;这个n个数之和是不是有什么深意啊&#…

Python中的类和对象(6)

文章目录1.多态2.类继承的多态3.自定义函数的多态4.鸭子类型5.思维导图1.多态 多态在编程中是一个非常重要的概念&#xff0c;它是指同一个运算符、函数或对象在不同的场景下&#xff0c;具有不同的作用效果&#xff0c;这么一个技能。 我们知道加号&#xff08;&#xff09;…