Fix: Alignment issue for TwoLineListItem#6193
Conversation
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request adds an alignment setting of 'Pos.CENTER' to the 'TwoLineListItem' constructor. The reviewer suggests using 'Pos.CENTER_LEFT' instead, to ensure that the list items are correctly aligned to the left horizontally while remaining vertically centered.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| getStyleClass().add(DEFAULT_STYLE_CLASS); | ||
| setMouseTransparent(true); | ||
|
|
||
| setAlignment(Pos.CENTER); |
There was a problem hiding this comment.
/gemini Pos.CENTER_LEFT 是否会对其他情况产生影响?
There was a problem hiding this comment.
使用 Pos.CENTER_LEFT 是针对列表项(List Item)的通用最佳实践。在 JavaFX 中,setAlignment(Pos.CENTER_LEFT) 仅会影响容器内子组件的对齐方式,而不会改变容器本身的布局行为(如 VBox 的填充策略)。
只要 TwoLineListItem 的父容器没有强制其子组件进行拉伸(例如 VBox 的 fillWidth 属性为 true),使用 Pos.CENTER_LEFT 能够确保内容在垂直方向居中,同时在水平方向保持左对齐,这通常是列表项最符合直觉的视觉呈现方式。它不会对其他非列表场景产生负面影响,除非该组件被设计为在某些特定布局中需要强制水平居中,但在列表项的语境下,这通常不是预期的行为。
| setAlignment(Pos.CENTER); | |
| setAlignment(Pos.CENTER_LEFT); |


修复 TwoLineListItem 对齐问题
缘由
合并 #6186 后,在不同字体下, TwoLineListItem 存在对齐问题。
涉及的 Issue
#6191
更改
实况
字体:Tahoma