<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    咖啡伴侶

    呆在上海
    posts - 163, comments - 156, trackbacks - 0, articles - 2

    DashboardLayout之scroll版本AutoTableLayout

    Posted on 2013-03-12 13:33 oathleo 閱讀(1568) 評論(0)  編輯  收藏 所屬分類: Android
    iosched 里的DashboardLayout 在scroll里好像有點(diǎn)問題,一個(gè)類就事情,沒時(shí)間調(diào)了,自己寫了個(gè)

    1 1 import android.content.Context;
     2 import android.view.View;
     3 import android.widget.LinearLayout;
     4 
     5 public class AutoTableLayout extends LinearLayout {
     6 
     7     private int mMaxChildWidth = 0;
     8     private int mMaxChildHeight = 0;
     9 
    10     //列數(shù)
    11     private int column = 0;
    12     //是否自定義列數(shù)
    13     private boolean isCustomColumn = false;
    14     
    15     public AutoTableLayout(Context context) {
    16         super(context, null);
    17     }
    18 
    19     public AutoTableLayout(Context context, int col) {
    20         super(context, null);
    21         column = col;
    22         isCustomColumn = true;
    23     }
    24 
    25     @Override
    26     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    27         mMaxChildWidth = 0;
    28         mMaxChildHeight = 0;
    29 
    30         final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.AT_MOST);
    31         final int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.AT_MOST);
    32 
    33         final int count = getChildCount();
    34         for (int i = 0; i < count; i++) {
    35             final View child = getChildAt(i);
    36             if (child.getVisibility() == GONE) {
    37                 continue;
    38             }
    39 
    40             child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
    41 
    42             mMaxChildWidth = Math.max(mMaxChildWidth, child.getMeasuredWidth());
    43             mMaxChildHeight = Math.max(mMaxChildHeight, child.getMeasuredHeight());
    44         }
    45 
    46         int width = resolveSize(mMaxChildWidth, widthMeasureSpec);
    47 
    48         // 每行個(gè)數(shù)
    49         if (!isCustomColumn) {
    50             column = (int) Math.floor((double) width / mMaxChildWidth);
    51         }
    52          
    53         int row = (int) Math.ceil((double) count / column);
    54 
    55         int height = mMaxChildHeight * row;
    56         setMeasuredDimension(width, height);
    57 
    58     }
    59 
    60     @Override
    61     protected void onLayout(boolean changed, int l, int t, int r, int b) {
    62         int width = r - l;
    63         int height = b - t;
    64         
    65         final int count = getChildCount();
    66         
    67         int left, top;
    68         int col, row;
    69         
    70         int gap = (width - column * mMaxChildWidth) / (column + 1);
    71         
    72         for (int i = 0; i < count; i++) {
    73             final View child = getChildAt(i);
    74 
    75             row = (int) Math.floor( (double)i / column);
    76             col = i % column;
    77 
    78             left = l + (col + 1) * gap + col * mMaxChildWidth;
    79             top = t + row * mMaxChildHeight;
    80             
    81             
    82             child.layout(left, top, left + mMaxChildWidth, top + mMaxChildHeight);
    83         }
    84     }
    85 
    86 }
    主站蜘蛛池模板: 3d动漫精品啪啪一区二区免费| 亚洲综合国产一区二区三区| 亚洲人成无码www久久久| 国产精品亚洲片夜色在线| 国产精品免费αv视频| 日韩成人在线免费视频| 亚洲综合一区二区精品导航| av电影在线免费看| 我想看一级毛片免费的| 亚洲欧洲精品视频在线观看| 国产偷伦视频免费观看| 亚洲自偷自偷在线制服| 久久99精品免费一区二区| 亚洲一区二区视频在线观看| 免费激情网站国产高清第一页 | 国产精品亚洲色婷婷99久久精品| 免费中文熟妇在线影片| 亚洲国产成人久久三区| 免费视频专区一国产盗摄| 亚洲男人天堂av| 国产精品免费观看| 亚洲av无码专区在线观看亚| 在线观看亚洲免费视频| 免费一级毛片在线播放放视频| 免费一级特黄特色大片在线| 羞羞的视频在线免费观看| 亚洲精品亚洲人成人网| 免费A级毛片无码视频| 2020国产精品亚洲综合网| 青青青国产色视频在线观看国产亚洲欧洲国产综合 | 国产91成人精品亚洲精品| 亚洲中文字幕无码爆乳av中文| 国产午夜无码精品免费看| 亚洲精品国产手机| 亚洲精品和日本精品| 久久精品人成免费| 国产亚洲精品精品精品| 亚洲成亚洲乱码一二三四区软件| 亚洲网站在线免费观看| 色多多免费视频观看区一区| 亚洲AV无码成人专区片在线观看 |