2

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

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

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

4

3 回答 3

0

感谢您的反馈意见。经团队确认,目前TableLayoutManager不支持ListContainer. grid of images (GridLayout)目前也不支持该功能。请继续关注HarmonyOS官网。

于 2021-08-03T03:23:15.850 回答
0

根据 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);
于 2021-08-03T20:13:55.403 回答