亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 GXUI 中設置 LinearLayout 的大小

如何在 GXUI 中設置 LinearLayout 的大小

Go
陪伴而非守候 2021-10-18 15:17:24
我正在嘗試使用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 關注
  • 215 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號