【问题标题】:How to display grid of images (GridLayout) in Harmony OS?如何在 Harmony OS 中显示图像网格(GridLayout)?
【发布时间】:2021-07-30 13:20:24
【问题描述】:

我正在尝试使用 TableLayoutManager 在 ListContainer 中的网格视图中显示图像。但是,它不是以图像网格的形式显示,而是显示图像列表。 对于下面使用的Eg代码,

ListContainer listContainer = (ListContainer) findComponentById(ResourceTable.Id_recyclerView);
TableLayoutManager tableLayoutManager = new TableLayoutManager();
tableLayoutManager.setOrientation(Component.VERTICAL);
tableLayoutManager.setColumnCount(3);
listContainer.setLayoutManager(tableLayoutManager);

您能否告知,上述代码中的问题是什么,以及我们如何在 Harmony OS 中实现图像/项目网格。

【问题讨论】:

    标签: java android huawei-mobile-services huawei-developers harmonyos


    【解决方案1】:

    感谢您的反馈。经团队确认,目前ListContainer 不支持TableLayoutManager。并且 grid of images (GridLayout) 函数现在也不支持。请继续关注鸿蒙官方网站。

    【讨论】:

      【解决方案2】:

      根据 HarmonyOS 开发者网站的文档,我认为您需要设置所需的列数和行数。 https://developer.harmonyos.com/en/docs/documentation/doc-guides/ui-java-layout-tablelayout-0000001060379893

      Component component = findComponentById(ResourceTable.Id_text_one);
      TableLayout.LayoutConfig tlc = new TableLayout.LayoutConfig(vp2px(72), vp2px(72));
      tlc.columnSpec = TableLayout.specification(TableLayout.DEFAULT, 2);
      tlc.rowSpec = TableLayout.specification(TableLayout.DEFAULT, 2);
      component.setLayoutConfig(tlc);
      

      【讨论】:

        【解决方案3】:
        猜你喜欢
        • 2016-04-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-10-09
        • 1970-01-01
        相关资源
        最近更新 更多