如何在Flexbox布局Android

时间:2019-06-13 10:26:54

标签: android flexbox

我已使用flexbox布局显示自定义列表。我想获取每列中的最低项目索引。

FlexboxLayoutManager附带了许多方法。但是任何方法,都不会返回我想要的值。layoutManager.getFlexLines()和layoutManager.getFlexLinesInternal()会被使用,但这些方法也会返回空列表。 Screen shot

FlexboxLayoutManager layoutManager = new FlexboxLayoutManager(mcontext);
    layoutManager.setFlexDirection(FlexDirection.COLUMN);
    layoutManager.setJustifyContent(JustifyContent.FLEX_START);
    layoutManager.setFlexWrap(FlexWrap.WRAP);
    myViewHolder.rvItem.setLayoutManager(layoutManager);
    itemAdapter = new ItemAdapter(mcontext,mData.get(i));
    myViewHolder.rvItem.setAdapter(itemAdapter);
    myViewHolder.rvItem.setItemViewCacheSize(20);

    int a = layoutManager.getAlignContent();
    int b = layoutManager.getAlignItems();
    int c = layoutManager.getJustifyContent();
    int d = layoutManager.getMaxLine();
    int e = layoutManager.getLargestMainSize();
    int f = layoutManager.getFlexItemCount();
    int g = layoutManager.getSumOfCrossSize();
    int h = layoutManager.getFlexWrap();
    int j = layoutManager.getChildCount();
    int k = layoutManager.getBaseline();
    int l = layoutManager.getItemCount();
    List<FlexLine>  flexLines = layoutManager.getFlexLines();
    List<FlexLine>  flexLines1 = layoutManager.getFlexLinesInternal();

    int m = layoutManager.getHeight();

    System.out.println("l_index "+ a+" "+ b+" "+c +" "+d +" "+e+" "+g+" "+h+" "+j+" "+k+" "+l+" "+flexLines+" " +flexLines1+ " "+ " "+f + " "+m +" ");

06-13 15:51:16.420 5229-5229 / com.salesplay.kotdisplay I / System.out:l_index 5 4 0 -1 0 0 1 0 -1 4 [] [] 0 0 0

这是我的Logcat上显示的结果。

0 个答案:

没有答案