我正在開發一個列表,我想通過以紅色顯示字體顏色來突出顯示某些行。這可能嗎?如何設置libgdx列表中特定行的顏色?
編輯: 好吧,這裏簡化我的代碼版本:
Skin defListSkin = new Skin(Gdx.files.internal("data/uiskin.json"));
List listHistory = new List<String>(defSkin);
// Here I set the general font color for the list
List.ListStyle listStyle = listHistory.getStyle();
listStyle.font = fontList;
listStyle.fontColorUnselected = Color.LIGHT_GRAY;
listHistory.setStyle(listStyle);
String[] items = new String[20];
// Example of item[]
// item[0]: "John 12"
// item[1]: "Amy -3" <-- I want certain lines to appear in red (e.g. those with negative numbers)
// Populate the list
listHistory.setItems(items);
// Drawing the list (actual draw happens in render() of course)
Table myTable = new Table();
myTable.add(listHistory);
stage.addActor(myTable);
太過模糊:)給我們帶來什麼你試過,也許你正試圖實現的截圖。 – Enigo
你現在怎麼畫線?你有某種'列表'。你可以做'spriteBatch.setColor(..)'。 –
Madmenyo