我正在尝试使用GXUI制作一个网格,我LinearLayout用于行和列,但是我在调整它的大小时遇到了问题。package mainimport ( "fmt" "github.com/google/gxui" "github.com/google/gxui/math" "github.com/google/gxui/drivers/gl" "github.com/google/gxui/samples/flags" "github.com/google/gxui/themes/dark")func appMain(driver gxui.Driver) { theme := dark.CreateTheme(driver) window := theme.CreateWindow(800, 600, "Grid") window.SetScale(flags.DefaultScaleFactor) window.OnClose(driver.Terminate) size := window.Viewport().SizeDips() grid := theme.CreateLinearLayout() grid.SetDirection(gxui.TopToBottom) grid.SetSizeMode(gxui.Fill) for y := 0; y < 4; y++ { row := theme.CreateLinearLayout() row.SetDirection(gxui.LeftToRight) for x := 0; x < 4; x++ { label := theme.CreateLabel() label.SetText(fmt.Sprintf("%d", y*4+x)) cell := theme.CreateLinearLayout() cell.SetDirection(gxui.TopToBottom) cell.SetSize(math.Size{W: size.W/4, H: size.H/4}) // not actually resizes cell.AddChild(label) row.AddChild(cell) } grid.AddChild(row) } window.AddChild(grid)}func main() { gl.StartDriver(appMain)}这是结果:
1 回答
- 1 回答
- 0 关注
- 194 浏览
添加回答
举报
0/150
提交
取消