我的任务很简单,我有一组名称,每个名称都作为单独的文本视图添加。但是我的一些数组很长,并且文本视图太大而无法在屏幕上显示。结果非常难看,我不知道如何解决它。我尝试使用所有不同的(据我所知)布局类型,但似乎没有一个能完成我想要的工作。我只是希望他们在没有更多空间时跳到新行。有点像它的工作原理:https ://www.w3schools.com/css/tryit.asp?filename=trycss_float_elements
这是它的外观:在此处输入图像描述 这是我当前的代码:
for (game in games) {
verticalLayout {
padding = dip(5)
//border color
verticalLayout {
padding = dip(3)
backgroundColor = Color.rgb(227, 227, 227)
//background golor
verticalLayout {
padding = dip(3)
backgroundColor = Color.rgb(250, 250, 250)
linearLayout {
var players = App.instance.db.getPlayerScores(game.toLong())
var isFirst = true
var colors = ArrayList(Arrays.asList(Color.BLUE, Color.RED, Color.GREEN, Color.MAGENTA, Color.YELLOW,Color.BLUE, Color.RED, Color.GREEN, Color.MAGENTA, Color.YELLOW,Color.BLUE, Color.RED, Color.GREEN, Color.MAGENTA, Color.YELLOW))
var ci = 0;
for (player in players) {
if (!isFirst) {
textView {
text = " vs. "
textSize = 18f
}
}
textView {
text = player.name
textSize = 24f
textColor = colors[ci]
ci += 1
}
isFirst = false
}
}
textView {
val date = App.instance.db.getGameTime(game)
text = date.substring(0, 16)
textSize = 18f
textColor = Color.GRAY
}
}
}
}
}
如果下一个项目太大而无法容纳,应该有某种解决方案而不计算linearLayout中内容的长度并使其创建一个新的leanaerLayout?如果不是……那怎么可能呢?