回收 - 查看不同的列号

问题描述 投票:-1回答:3

您好,我可以使用recyclerview布局管理器制作这样的图像吗?这个图像显示我想要做的事先谢谢。

java android
3个回答
0
投票

使用ReycyleView使用GridLayoutManager

manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
    if (position == 0) {
        return 2; //  Splitting into 2 columns
    } else {
        return 3; // Splitting into 3 columns
    }
}

});


0
投票

是的你可以...在recycler_adapter检查position == 0然后使两个cardsview visible并设置它们...并在else {cardview4 ,cardview5,cardview6 visible并设置它们并使cardview1和cardview2 Gone膨胀布局将包含一个相对lat你与两个horizontal linearlayouts只是hide make the layouts gone and visible at proper position in onBind()


0
投票

为了实现这一观点,我认为GridLayoutManager用它的setSpanSizeLookup()方法是最好的选择。你可以在this answer找到完整的解释。如果你在实施时遇到任何问题,你可以问。

© www.soinside.com 2019 - 2024. All rights reserved.