最新Android ViewGroup介绍+实例,2024年最新腾讯面试算法题用什么软件

架构师筑基包括哪些内容

我花了将近半个月时间将:深入 Java 泛型.、注解深入浅出、并发编程.、数据传输与序列化、Java 虚拟机原理、反射与类加载、高效 IO、Kotlin项目实战等等Android架构师筑基必备技能整合成了一套系统知识笔记PDF,相信看完这份文档,你将会对这些Android架构师筑基必备技能有着更深入、更系统的理解。

由于文档内容过多,为了避免影响到大家的阅读体验,在此只以截图展示部分内容

注:资料与上面思维导图一起看会更容易学习哦!每个点每个细节分支,都有对应的目录内容与知识点!



这份资料就包含了所有Android初级架构师所需的所有知识!

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

*/

@Override

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

super.onMeasure(widthMeasureSpec, heightMeasureSpec);

MLog.e(getClass().getName(),“onMeasure”);

// 获得它的父容器为它设置的测量模式和大小

int sizeWidth = MeasureSpec.getSize(widthMeasureSpec);

int sizeHeight = MeasureSpec.getSize(heightMeasureSpec);

int modeWidth = MeasureSpec.getMode(widthMeasureSpec);

int modeHeight = MeasureSpec.getMode(heightMeasureSpec);

// 如果是warp_content情况下,记录宽和高

int width = 0;

int height = 0;

//记录每一行的宽度,width不断取最大宽度

int lineWidth = 0;

//每一行的高度,累加至height

int lineHeight = 0;

int count = getChildCount();

int left = getPaddingLeft();

int top = getPaddingTop();

// 遍历每个子元素

for (int i = 0; i < count; i++) {

View child = getChildAt(i);

if (child.getVisibility() == GONE)

continue;

// 测量每一个child的宽和高

measureChild(child, widthMeasureSpec, heightMeasureSpec);

// 得到child的lp

ViewGroup.LayoutParams lp = child.getLayoutParams();

// 当前子空间实际占据的宽度

int childWidth = child.getMeasuredWidth() + childHorizontalSpace;

// 当前子空间实际占据的高度

int childHeight = child.getMeasuredHeight() + childVerticalSpace;

if (lp != null && lp instanceof MarginLayoutParams) {

MarginLayoutParams params = (MarginLayoutParams) lp;

childWidth += params.leftMargin + params.rightMargin;

childHeight += params.topMargin + params.bottomMargin;

}

//如果加入当前child,则超出最大宽度,则的到目前最大宽度给width,类加height 然后开启新行

if (lineWidth + childWidth > sizeWidth - getPaddingLeft() - getPaddingRight()) {

width = Math.max(lineWidth, childWidth);// 取最大的

lineWidth = childWidth; // 重新开启新行,开始记录

// 叠加当前高度,

height += lineHeight;

// 开启记录下一行的高度

lineHeight = childHeight;

child.setTag(new Location(left, top + height, childWidth + left - childHorizontalSpace, height + child.getMeasuredHeight() + top));

} else {

// 否则累加值lineWidth,lineHeight取最大高度

child.setTag(new Location(lineWidth + left, top + height, lineWidth + childWidth - childHorizontalSpace + left, height + child.getMeasuredHeight() + top));

lineWidth += childWidth;

lineHeight = Math.max(lineHeight, childHeight);

}

}

width = Math.max(width, lineWidth) + getPaddingLeft() + getPaddingRight();

height += lineHeight;

sizeHeight += getPaddingTop() + getPaddingBottom();

height += getPaddingTop() + getPaddingBottom();

setMeasuredDimension((modeWidth == MeasureSpec.EXACTLY) ? sizeWidth : width, (modeHeight == MeasureSpec.EXACTLY) ? sizeHeight : height);

}

/**

* 记录子控件的坐标

*/

public class Location {

public Location(int left, int top, int right, int bottom) {

this.left = left;

this.top = top;

this.right = right;

this.bottom = bottom;

}

public int left;

public int top;

public int right;

public int bottom;

}

//计算当前View以及子View的位置

@Override

protected void onLayout(boolean changed, int l, int t, int r, int b) {

MLog.e(getClass().getName(),“onLayout”);

//获取子View个数

int count = getChildCount();

for (int i = 0; i < count; i++) {

//获取子View

View child = getChildAt(i);

//判断是否显示

if (child.getVisibility() == GONE)

continue;

//获取子View的坐标

Location location = (Location) child.getTag();

//设置子View位置

child.layout(location.left, location.top, location.right, location.bottom);

}

}

@Override

protected void onSizeChanged(int w, int h, int oldw, int oldh) {

super.onSizeChanged(w, h, oldw, oldh);

MLog.e(getClass().getName(),“onSizeChanged”);

}

@Override

protected void onDraw(Canvas canvas) {

super.onDraw(canvas);

MLog.e(getClass().getName(),“onDraw”);

}

}

2.使用自定义CustomLayout

<?xml version="1.0" encoding="utf-8"?>

<com.scc.demo.view.CustomLayout xmlns:android=“http://schemas.android.com/apk/res/android”

xmlns:custom=“http://schemas.android.com/apk/res-auto”

android:layout_width=“match_parent”

android:layout_height=“match_parent”

android:layout_margin=“@dimen/dimen_20”

custom:horizontalSpace=“10dp”

custom:verticalSpace=“20dp”>

<TextView

style=“@style/TvStyle”

android:text=“破阵子·为陈同甫赋壮词以寄” />

<TextView

style=“@style/TvStyle”

android:text=“宋·辛弃疾” />

<TextView

style=“@style/TvStyle”

android:text=“醉里挑灯看剑” />

<TextView

style=“@style/TvStyle”

android:text=“梦回吹角连营” />

<TextView

style=“@style/TvStyle”

android:text=“八百里分麾下炙” />

<TextView

style=“@style/TvStyle”

android:text=“五十弦翻塞外声” />

<TextView

style=“@style/TvStyle”

android:text=“沙场秋点兵” />

<TextView

style=“@style/TvStyle”

android:text=“马作的卢飞快” />

<TextView

style=“@style/TvStyle”

android:text=“弓如霹雳弦惊(增加点长度)” />

<TextView

style=“@style/TvStyle”

android:text=“了却君王天下事” />

<TextView

style=“@style/TvStyle”

android:text=“赢得生前身后名” />

<TextView

style=“@style/TvStyle”

android:text=“可怜白发生!” />

</com.scc.demo.view.CustomLayout>

3.自定义属性

在app/src/main/res/values/attrs.xml中添加属性

<?xml version="1.0" encoding="utf-8"?>

4.使用自定义属性

  • 在xml中使用

一定要添加:xmlns:test=”http://schemas.android.com/apk/res-auto”添加之后才能在xml中自定义属性,如下代码:

<com.scc.demo.view.CustomLayout xmlns:android=“http://schemas.android.com/apk/res/android”

xmlns:custom=“http://schemas.android.com/apk/res-auto”

android:layout_width=“match_parent”

android:layout_height=“match_parent”

android:layout_margin=“@dimen/dimen_20”

文末

当你打算跳槽的时候,应该把“跳槽成功后,我能学到什么东西?对我的未来发展有什么好处”放在第一位。这些东西才是真正引导你的关键。在跳槽之前尽量“物尽其用”,把手头上的工作做好,最好是完成了某个项目或是得到提升之后再走。跳槽不是目的,而是为了达到最终职业目标的手段

最后祝大家工作升职加薪,面试拿到心仪Offer


网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

位。这些东西才是真正引导你的关键。在跳槽之前尽量“物尽其用”,把手头上的工作做好,最好是完成了某个项目或是得到提升之后再走。跳槽不是目的,而是为了达到最终职业目标的手段**

最后祝大家工作升职加薪,面试拿到心仪Offer

[外链图片转存中…(img-q9IY3Cpb-1715362811744)]
[外链图片转存中…(img-7nv087fo-1715362811744)]

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值