Ответ 1
РЕДАКТИРОВАТЬ:
Немного изменив ваш css:
.list-cell:filled:selected:focused, .list-cell:filled:selected {
-fx-background-color: linear-gradient(#328BDB 0%, #207BCF 25%, #1973C9 75%, #0A65BF 100%);
-fx-text-fill: white;
}
.list-cell:even { /* <=== changed to even */
-fx-background-color: white;
}
.list-cell:filled:hover {
-fx-background-color: #0093ff;
-fx-text-fill: white;
}
Этот css создает следующую презентацию:
Означает ли это, что вы ожидаете?
Я изменил odd
к even
. Первая ячейка четная, потому что ее значение индекса равно 0 (ноль). Также -fx-cell-hover-color
недействителен. Я изменил его на -fx-background-color
где это необходимо или удалил.
Исходный текст: (обратите внимание, что это имеет другую интерпретацию нечетного/четного)
Мой прием будет таким:
(Я включил ваши требования в нумерованный список для справки в css. Я также сделал градиент более очевидным и добавил зеленый фон для четных ячеек.)
/*
1. Odd rows with white background color;
2. ListView: when mouse over an item, highlight with a blue shade;
3. ListView: when an item is selected, paint it with a gradient;
4. ListView: when focus is lost from ListView, selected item should be painted with gradient;
5. ListView: all items will start with text-fill black. But on mouse over and/or selected it will change to white.
*/
.list-cell:filled:selected:focused, .list-cell:filled:selected {
/* 3:, 4: */
-fx-background-color: linear-gradient(#333 0%, #777 25%, #aaa 75%, #eee 100%);
-fx-text-fill: white; /* 5 */
}
.list-cell { -fx-text-fill: black; /* 5 */ }
.list-cell:odd { -fx-background-color: white; /* 1 */ }
.list-cell:even { -fx-background-color: #8f8; /* for information */ }
.list-cell:filled:hover {
-fx-background-color: #00f; /* 2 */
-fx-text-fill: white; /* 5 */
}
Это приводит к этому рендерингу: