本文主要介紹自動換行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眼鏡