【问题标题】:GridLayout, GridView, RecyclerView... for a 2x8 and 4x8 gridGridLayout、GridView、RecyclerView... 用于 2x8 和 4x8 网格
【发布时间】:2020-12-18 20:20:55
【问题描述】:

我想制作两个单独的网格,一个有 2 列 8 行,另一个有 4 列 8 行。我应该选择哪种布局?它只需要垂直工作,并且顶部应该有一些空间用于按钮。我不希望任何元素消失,但我也不希望滚动查看所有元素。

【问题讨论】:

    标签: android-layout gridview android-recyclerview android-gridlayout


    【解决方案1】:

    在设置 RecyclerView 时,您可以使用 GridLayoutManager 而不是 LinearLayoutManager。

    recyclerView.setLayoutManager(new GridLayoutManager(this, numberOfColumns));
    

    此外,本教程将为您提供更多详细信息https://www.android-examples.com/android-recyclerview-with-gridview-gridlayoutmanager/

    【讨论】:

      猜你喜欢
      • 2019-05-02
      • 1970-01-01
      • 2013-05-14
      • 2014-08-02
      • 1970-01-01
      • 2023-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多