让自定义ViewGroup支持Padding

Zabbix-01简单导入MIB文件并测试 这里写自定义目录标题安装 MIB文件启用MIB文件测试MIB文件 MIB文件 MIB代表管理信息库。 MIB文件允许您使用OID(对象标识符)的文本表示。 ##例如: ifHCOutOctets 是OID【1.3.6.1.2.1.31.1.1.1.10】的文本表示 安装 MIB文件 在基于Debian的系统上: # apt install snmp-mibs-downloader # download-mibs 在基于RedHat的系统上: # yum install net-snmp-libs 启用M 阅读详情

自定义控件系列:
秒懂OnMeasure
秒懂OnLayout
让自定义ViewGroup里的子控件支持Margin
让自定义ViewGroup支持Padding
自定义ViewGroup的一个综合实践 FlowLayout

知识点:

  1. 让自定义ViewGroup支持Padding,需要自定义ViewGroup在自身的onMeasure和onLayout里去处理Padding即可

因为padding很容易获得,不像是Margin那么麻烦,
另外与margin不同的是,padding是自定义ViewGroup的padding,只有四个padding,而margin是子控件的margin,每个子控件都会有四个margin,所有在处理上注意一下

应用

1. 支持padding

第一步:onMeasure里处理Padding

其实就是在AT_MOST模式下,让ViewGroup自身的宽高加上padding,变大一点
EXACTLY模式是不用处理的,因为他已经指定了宽高,按照他指定的来就行了

在这里插入图片描述

  /**
     * 计算本View在AtMost模式下的宽高
     * 其他代码都是不用动的,在这里写下你特有的逻辑就可以
     *
     * @param widthMeasureSpec
     * @param heightMeasureSpec
     * @return
     */
    private Point caculateAtMostSize(int widthMeasureSpec, int heightMeasureSpec) {

        int width = 0;
        int height = 0;

        int count = getChildCount();
        for (int i = 0; i < count; i++) {
            View child = getChildAt(i);
            // 测量一下子控件的宽高
            measureChild(child, widthMeasureSpec, heightMeasureSpec);

            // 得到MarginLayoutParams,margin就在这里保存着
            MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
            // 获得子控件的宽高(需要加上对应的margin,让控件的宽高包含margin,
            // 这样才能让自定义的viewgroup在计算自身在AtMost模式的尺寸时候考虑到这些margin)
            int childWidth = child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin;
            int childHeight = child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin;

            // 因为我们的自定义View模拟的是竖向的LinearLayout,所以:
            // 控件的宽度为所有子控件里,宽度最大的那个view的宽度,
            // 控件高度是所有子空间的高度之和
            width = Math.max(childWidth, width);
            height += childHeight;
        }

        width += (getPaddingLeft() + getPaddingRight());
        height += (getPaddingTop() + getPaddingBottom());
        return new Point(width, height);
    }
第二步:onLayout里处理Padding

在这里插入图片描述

  @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        int top = getPaddingTop();
        int count = getChildCount();
        for (int i = 0; i < count; i++) {

            View child = getChildAt(i);

            // 得到MarginLayoutParams,margin就在这里保存着
            MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();


            // 获得子控件的宽高(需要加上对应的margin,让控件的宽高包含margin)
            int childWidth = child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin;
            int childHeight = child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin;

            // 布局,就是设置好这个子控件的左上右下
            // 在布局的时候,考虑控件的margin,把子view摆放好
            // (这是一个竖向的LinearLayout,想想如何布置子控件)
            child.layout(lp.leftMargin+getPaddingLeft(),
                    top + lp.topMargin,
                    childWidth - lp.rightMargin+getPaddingLeft(),
                    top + childHeight - lp.bottomMargin);
            top += childHeight;

        }

    }

github源码之MyLinearLayoutWithMarginAndPadding

至此

  1. 自定义View(含Viewgroup)onMeasure里支持AT_MOST的模板代码
  2. 自定义Viewgroup的onLayout里支持Margin的模板代码
    都有了,真的是一样的套路,照抄即可
  3. 另外处理Margin和Padding的一些小逻辑,仔细想想也很容易写出来,大思路有了,小逻辑调试一下就出来了

参考:
《Android自定义开发入门与实践》感谢大神的著作

openclaw通俗入门系列4——智能体工作区 工作区 = 智能体的家,存放它的性格、记忆、技能。默认不是牢笼(可以用沙箱隔离)。建议放到私有 Git 备份,但绝对不要提交密钥! 阅读详情

相关推荐

从门禁到支付:Uniapp+NFC开发避坑指南(支持Mifare Classic)

本文详细介绍了Uniapp结合NFC技术开发门禁与支付系统的实战指南,特别针对Mifare Classic卡片进行深度优化。内容涵盖环境配置、设备兼容性处理、卡片安全机制解析以及高性能读写优化策略,帮助开发者快速实现跨平台的智能硬件交互解决方案。

t1u2v的博客 751

自定义控件(14)---ViewGroup绘制的Padding、margin注意

ViewGroup测量子元素有关,其中measureChildWithMargins和measureChildren类似只是加入了对Margins外边距的处理,ViewGroup提供对子元素测量的方法从measureChildren开始: measureChildren的逻辑很简单,通过父容器传入的widthMeasureSpec和heightMeasureSpec遍历子元素并调用measure

全干工程师 2861

PID调参避坑指南:为什么你的电机总是震荡?从比例带积分到微分实战解析

本文针对电机控制中常见的震荡问题,提供了一份PID调参实战指南。文章深入解析了比例(P)、积分(I)、微分(D)三个参数对系统稳定性的影响,揭示了比例增益过大是导致震荡的关键原因之一,并给出了从纯比例调试到引入积分、微分的系统化调参流程与避坑要点,帮助工程师快速实现电机平稳、精准的控制。

weixin_28223453的博客 460

自定义ViewGroup-自定义LayoutParams支持显示方位

自定义属性: 方位包含 4 个方向:左上角、右上角、左下角、右下角,在 attrs.xml 文件中,定义一个名为layout_position 的属性,类型为 enum,枚举出这 4 个值。 activity_ma

凌烟醉卧的博客 1568

【FLINK+Kerberos+kafka】在华为云上 bootstrap.server使用IP的GSS initiate failed 问题处理

目前互联网上所有的资料显示都是说没有正确设置KDC之类的,但本博主实际通过java代码低版本 如使用kafka-client 0.11.0 ,2.4.0等版本手动创建kafkaconfig 或者使用华为云的LoginUtils类 都能够正常链接,所以应该是高版本添加了相关配置,或者flink在subtask 创建kafkaAdminClient时 丢弃或使用了默认的一些配置行为,导致了客户端和kdc验证之间出现了principal 不一致导致验证失败。client.dns.lookup配置项作用。

honghanyue1791的博客 576

从仿真到流片:手把手教你优化65nm CMOS电荷泵的电流匹配与稳定性

本文详细介绍了在65nm CMOS工艺下优化电荷泵电流匹配与稳定性的工程实践指南。通过蒙特卡洛仿真、运放反馈结构版图技巧和全差分结构设计,实现优于1%的电流匹配精度和±2%以内的电流稳定性,特别针对current mismatch问题提供了有效的解决方案。

weixin_42522320的博客 417

ViewGroup.MarginLayoutParams

/* 每个子布局的布局信息,子布局是要支持margin(外边距)属性的。 * * android.R.styleable.ViewGroup_MarginLayouts是这个类所支持的子控件的一个属性列表,子控件拥有这些属性 * * 它继承于 ViewGroup.LayoutParams(只有宽高属性,宽高是包含padding的,即包含内边距) */ public static class MarginLayoutParams extends ViewGrou

众智成程的专栏 5106

别再纠结了!车规MCU选M7还是R52?一张图看懂你的车身控制器/域控制器该用谁

本文深入探讨车规MCU选型中Cortex-M7与Cortex-R52的核心差异,提供基于安全等级与实时性需求的选型决策图。通过对比ASIL认证、实时性能及成本效益,帮助工程师在车身控制器/域控制器设计中做出精准选择,避免潜在风险与隐性成本。

weixin_42628688的博客 397

Android中LayoutParams总结和用法

原因在于LinearLayout(或其他继承自ViewGroup的layout,如:RelativeLayout)在进行递归布局的时候,LinearLayout会获取子View的LayoutParams,并强制转换成LinearLayout.LayoutParams From: http://blog.csdn.net/liuhaomatou/article/details/2289

fyfcauc的专栏 1285

FPGA:UART串口接收(高干扰情况)

在上一篇文章中介绍过UART串口接收模块,其中一个需要优化的方向就是在高干扰情况下,如何实现可靠的UART串口接收任务。

weixin_50164178的博客 1672

ThingsBoard教程(七):模拟设备遥测

前言 各位读者好,截止目前,ThingsBoard系列文章已经做了六篇,分别是 ThingsBoard教程(一):ThingBoard介绍及安装 ThingsBoard教程(二):租户,租户配置,部件组模块的使用 ThingsBoard教程(三):系统设置模块的使用 ThingsBoard教程(四):规则链简介与操作 ThingsBoard教程(五):客户,资产管理 ThingsBoard教程(六):设备管理 上一篇我们讲解了如何使用设备管理来对设备进行增删改查,和设备配置的一些基本概念,本篇文章就带大

知无涯 4586

Android自定义ViewGroup(自定义LayoutParams)

原文链接:https://blog.csdn.net/ldld1717/article/details/80458917 2. 自定义LayoutParams 回想一下我们平时使用RelativeLayout的时候,在布局文件中使用android:layout_alignParentRight=“true”、android:layout_centerInParent="true"等各种属性,就能控制子控件显示在父控件的上下左右、居中等效果。   在View中有一个mLayoutParams的变量用来保存这个

Air723的博客 809

SPD-Conv+YOLOv8:空间深度转换卷积赋能小目标检测,从原理到实战的科研级优化指南

从理解SPD-Conv“空间到深度+逐步卷积”的核心设计,到亲手将其嵌入YOLOv8并验证在小目标场景的表现,再到基于此探索属于自己的科研与工程方向——这个过程能让你深刻理解“小目标特征保留”在检测任务中的核心价值。现在就开始行动,相信你会在小目标检测的“细节捕捉”之路上,走出一条属于自己的技术路径。实验通常会证明:嵌入SPD-Conv后,YOLOv8在小目标AP上提升5-8个百分点,mAP50-95提升3-5个百分点,而推理速度仅下降5%以内,充分体现了其“保细节+提精度”的优势。

m0_64661770的博客 163

自定义ViewGroup实现流式布局(支持ViewGroup Padding, 子View margin,每行高度可以不一样)

================================================================ 预留填坑 ================================================================ 先直接贴代码,注释真心很详细了: 大体思路,自定义一个ViewGroup,重写onMeasure,onLayout方法,

zxt0601的博客 9997

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

android自定义ViewGroup之瀑布流FlowLayout 简洁明了 支持padding和margin 100行代码搞定

android自定义ViewGroup之瀑布流FlowLayout 简洁明了 支持padding和margin 100行代码搞定FlowLayout完美解决购物类app参差不齐的标签、热门搜索等: 支持padding和margin 支持xml和java代码动态添加childView 简洁明了100行代码 效果图核心代码1、重写onMeasure:@Override protected voi

oYouHeBuKe123456的博客 632

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

一步一步使用自定义ViewGroup实现流式布局

/ 今日科技快讯 /近日,继上周推出员工“退休福利”后,腾讯今日宣布全面升级员工“职业里程碑”关怀方案。根据新方案,腾讯员工“职业里程碑”将从过去的三个节点升级为六个,即从原来的入...

郭霖 542

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

自定义View、ViewGroup(温习&实战&笔记)

自定义View、ViewGroup的最基本的支持要点 自定义View - onMeasure、onDraw wrap_content; padding; 自定义ViewGroup -onMeasure、onLayout wrap_content; padding; margin; 为啥View只需支持padding,而ViewGroup需要支持padding和margin...

json_it的博客 505

Android 自定义控件之继承ViewGroup创建新容器

欢迎大家来学习本节内容,前几节我们已经学习了其他几种自定义控件,分别是Andriod 自定义控件之音频条及 Andriod 自定义控件之创建可以复用的组合控件还没有学习的同学请先去学习下,因为本节将使用到上几节所讲述的内容。 在学习新内容之前,我们先来弄清楚两个问题: 1 . 什么是ViewGroup? ViewGroup是一种容器。它包含零个或以上的View及子View。

wuji3390的博客 313

自定义ViewGroup

引子:标准的自定义ViewGroup应该包含什么github第一部分 支持wrap_content 即当ViewGroup的宽、高使用wrap-content时,ViewGroup的高宽根据子View的实际大小来确定 如果你不处理的话,“wrap-content”的和 “match-parent”是一样的ViewGroup支持Padding 其子View支持margin 支持自定义属性

Android_Study_OK的博客 2287

Android自定义控件之继承ViewGroup创建新容器(四)

在学习新内容之前,我们先来弄清楚两个问题: 1 . 什么是ViewGroup? ViewGroup是一种容器。它包含零个或以上的View及子View。 2 . ViewGroup有什么作用? ViewGroup内部可以用来存放多个View控件,并且根据自身的测量模式,来测量View子控件

管满满 1万+

自定义ViewGroup的一个综合实践 FlowLayout

效果

Android_Study_OK的博客 346

自定义ViewGroup初步

自定义ViewGroup初步平时自定义View用的比较少,现在试着多写一些,下面记录一下第一个自定义ViewGroup的实现步骤功能是存放若干个Button,先从简单的开始效果:实现思路步骤: 创建java文件继承ViewGroup并添加构造方法,必须重写onLayout方法,这里先空着 public class ButtonGroup extends ViewGroup { public

Brioal Is Hardworking 575

自定义ViewGroup系列---CornerLayout案例

本篇来讲解自定义ViewGroup的案例CornerLayout的实现,该ViewGroup的效果是在4个角包含4个子view。 如下操作可以帮我们理解该ViewGroup的效果。 我们来分析下要实现这个ViewGroup的思路: 1,onMeasure() 测量流量 ①,如果CornerLayout是wrap_content的,那么其宽度是 Math.max(A.width,C.width) + Math.max(B.width,D.width),其高度是Math.max(A.height , B.he

u010869159的博客 291

android创建自定义容器,Android自定义控件之继承ViewGroup创建新容器

欢迎大家来学习本节内容,前几节我们已经学习了其他几种自定义控件,分别是Andriod 自定义控件之音频条及 Andriod 自定义控件之创建可以复用的组合控件还没有学习的同学请先去学习下,因为本节将使用到上几节所讲述的内容。在学习新内容之前,我们先来弄清楚两个问题:1 . 什么是ViewGroup?ViewGroup是一种容器。它包含零个或以上的View及子View。2 . ViewGroup有什...

weixin_36462532的博客 310

Android 如何自定义View?

Android 如何自定义View? 在看这篇博客之前可以先看View的工作原理 文章目录Android 如何自定义View?1. 自定义View1. 自定义View的分类1. 继承View重写onDraw方法2. 继承ViewGroup派生特殊的Layout3. 继承特定的View4. 继承特定的ViewGroup2. 自定义View须知1. 让View支持wrap_content2. 如果有必要,让View支持padding3. 尽量不要在View中使用Handler,没必要4. View中如果有线程或

qq_43621019的博客 1307

android自定义View全解

源码在这里:优快云本文主要有以下内容: * 自定义View的分类 * 自定义View的注意事项 * 自定义View的实现 * 自定义View使其支持wrap_content和padding * 自定义属性的实现过程首先,自定义View是为了达到更绚丽的效果。它相对来说也是一个比较难的技术体系,涉及到【View的层次结构】、【View事件分发机制】、【View的工作原理】、【View的弹性

jasonpeak的专栏 5586
上一篇: 让自定义ViewGroup里的子控件支持Margin
下一篇: 自定义ViewGroup的一个综合实践 FlowLayout
Android_Study_OK
博客等级 码龄11年 91粉丝 128原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值