首页 > 解决方案 > 如何创建项目宽度基于文本的行列表,

问题描述

我需要使用文本创建行列表,其中项目宽度基于项目文本请检查附加图像以供参考,

这里需要根据文本长度更改“ Breaking new ”文本项宽度。

标签: rokubrightscript

解决方案


这里是图像的 XML 组件:

<PosterGrid 
      id = "ChannelPosterGrid" 
      translation = "[ 10 , 10 ]"      
      caption1NumLines = "2" 
      caption2NumLines = "2"
      numColumns="4"
      numRows="6"
      focusBitmapUri="pkg:/images/imagegrid.png"
      itemSpacing = "[ 20, 20 ]" /> 

一、init()函数在postergrid中查找id m.top.grid = m.top.findNode("ChannelPosterGrid")

显示 rawlist 的 Brightscript 代码:

sub showpostergrid()
? " I am in showpostergrid() "
  m.top.grid.content = m.readPosterGridTask.content
' m.top.grid.FHDPosterUrl = m.readPosterGridTask.hdposterurl
end sub

用于读取 rawlist 的 Brightscript 代码:

sub readpostergrid()

'? "I am in readpostergrid() " m.top.gridcontenturi

  'the code of roPosterGrid
  m.ChannelPosterGrid = m.top.FindNode("ChannelPosterGrid")
  m.readPosterGridTask = createObject("roSGNode", "XmlReader")
' screen = createobject("roParagraphScreen")
' m.readPosterGridTask.backgroundColor = "008000"
  m.readPosterGridTask.contenturi = m.top.gridcontenturi
  m.readPosterGridTask.observeField("content", "showpostergrid")
' m.readPosterGridTask.contenturi = "pkg:/xml/AllChannel.xml"
' m.readPosterGridTask.contenturi = "http://api.delvenetworks.com/rest/organizations/59021fabe3b645968e382ac726cd6c7b/channels/1cfd09ab38e54f48be8498e0239f5c83/media.rss" 'Roku rss XML
  m.readPosterGridTask.color = "008000"
' screen.AddParagraph("Hello Nikunj")
  m.readPosterGridTask.control = "RUN"
end sub

推荐阅读