本文主要介绍自动换行linearlayout,下面一起看看自动换行linearlayout相关资讯。
转:(22条消息)radiogroup的博客带自动换行点击事件_再见美猴王_ -csdn博客。
公共类myradiogroup扩展了radio group { private static final string tag = radiogroupex public my radio group(context context){ super(context);} public my radio group(context context,attributeset attrs){ super(context,attrs);} @ override protected void on measure(int widthmeasurespec,int heightsmeasurespec){ int width size = measurespec . getsize(widthmeasurespec);int width mode = measure spec . get mode(widthmeasurespec);int heightsize = measure spec . getsize(heightsmeasurespec);int height mode = measure spec . get mode(heightmaurespec);//调用viewgroup的方法来度量视图measure children(width measure spec,heightmeasurespec);//最大宽度int maxwidth = 0;//累计高度int total height = 0;//当前行的累计线宽int line width = 0;//当前行的最大行高int maxline height = 0;//用于记录换行前的线宽和行高int oldheightint旧宽度;int count = get child count;//假设widthmode和heightmode都是_ most for(int i = 0;我数;i){ view child = get child at(i);边缘layout params params =(marginlayoutparams)child . getlayout params;//获取该行的最高oldheight = maxlineheight//当前最大宽度oldwidth = maxwidthint deltax = child . getmeasuredwidthparams . left margin params . right margin;if(line width deltax getpadding lightgetpadding lightwidth size){//如果换行,高度增加//与当前最大宽度相比,获得最宽宽度。你可以 t加上当前子的宽度,所以你用宽度maxwidth = math.max (line width,width);//reset width line width = deltax;//累积高度totalheight = oldheight//重置行高。当前视图属于下一行,因此当前最大行高是该子级的高度加上marginmax line height = child。getmeasureheight参数。上边距参数。底部边距;log.v(标签, maxheightcho 0-@ . com 总高度 - maxwidth: maxwidth);} else {//不换行,累计宽度linewidth = deltax//不换行,计算最高int deltay = child . getmeasureheightparams . top margin params . bottom margin;maxline height = math . max(maxline height,deltay);} if (i == count-1) {//在它之前不添加下一行。如果是最后一行,必须叠加最后一行的最高值:totalheight = maxlineheight//将计算的最后一行与其前面最宽的一行进行比较maxwidth = math.max(线宽,旧宽度);} }//加上当前容器的填充值maxwidth = getpadding lightgetpadding light;total height = getpadding topgetpadding bottom;setmeasureddimension(width mode = = measure spec。确实如此。宽度尺寸:最大宽度,高度模式==测量规格。确实如此。h:总高度);} @ override protected void onlayout(boolean changed,int l,int t,int r,int b){ int count = get child count;//pre是所有前一个子元素的添加位置。int pre left = getpadding left;int pretop = getpadding top;//记录每行的最高值int max height = 0;for(int i = 0;我数;i){ view child = get child at(i);marginlayoutparams params =(marginlayoutparams)child . getlayoutparams;//r-l是当前容器的宽度。如果子视图的累积宽度大于容器宽度,则换行。if(前置左参数。左边距子对象。getmeasurewidth参数。右边距getpadding light(r-l)){//reset pre left = getpadding left;//选择身高最大的孩子作为设置pretop = pretop maxheightmaxheight = getchildat(i)。getmeasuredheightparams . top margin params . bottom margin;} else {//不换行,计算最大高度max height = math.max (max height,child。getmeasureheight参数。上边距参数。下边距);}//左坐标intleft = prelefparams。左边距;//top coordinate int top = pretop params . top margin;int right = left child . getmeasuredwidth;int bottom = top child . getmeasuredheight;//子视图的layout child.layout (left,top,right,bottom);//计算布局后,preleft = params的值。leftmarginchild。getmeasurewidth参数。右边距;}}}标签:
宽度包装
了解更多自动换行linearlayout相关内容请关注本站点。
三星固态sn码编码规则
电芯对身体的伤害(电芯容易坏吗)
插上u盘显示格式化怎么修复,U盘插入电脑打开提示需要格式化怎么恢复数据
ryzen53600相当于英特尔的哪个(ryzen 5 3600相当于)
电脑硬盘接线方法图,固态硬盘怎么接线
自动换行linearlayout
微信订阅号消息为什么不按时间排序发送(为什么微信订阅号消息不按时间顺序)
苹果系统更新以后还能换回以前的吗(苹果系统更新能不能换回去)
如何安装win10镜像(怎么直接安装w10镜像系统)
游戏盒子推荐软件(游戏盒app推荐)
电脑u盘启动盘有什么作用吗(电脑u盘启动盘是什么盘)
手机变砖怎么办,我手机变砖了怎么办
云闪付转账失败退款吗安全吗(云闪付转账失败钱一直没退回来怎么办)
戴尔11代cpu装win7(戴尔11代笔记本怎么装系统)
苹果内存灰色怎么删除掉(苹果内存灰色怎么删除不了)
酷派大神f1怎么关闭瀑布流,瀑布流关不掉
美版s版 怎么样,美版iphone怎么样
键盘被锁打不了字(电脑键盘锁住了打不了字怎么解锁)
bp程序是什么(bp程序全称)
万维的3d显示屏怎么样,海尔LE50A900K 使用什么3D眼镜