小编Dan*_*iel的帖子

在javafx Listview中隐藏垂直滚动条

我已经尝试了几个小时,似乎无法在任何地方找到答案。我有2个与同一个ListView有关的问题,其中1个比另一个严重。

我正在尝试匹配Java中提供给我的设计。列表视图应如下所示

这是从设计

目前我已经达到

我目前的努力

我创建了一个Custom ListCell来保存所有视图(尚未重构,因此可能看起来有些杂乱)

import HolderClasses.MenuItem;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;

public class CustomListCell extends ListCell<MenuItem>{

    private Image mImage;
    private String mText;
    private AnchorPane background;
    private ImageView imageHolder;
    private VBox colourStrip;
    private Label mTextLabel;

    public CustomListCell(){

        background = new AnchorPane();
        imageHolder = new ImageView();
        mTextLabel = new Label();
        imageHolder.setFitHeight(40.0);
        imageHolder.setFitWidth(40.0);
        imageHolder.getStyleClass().add("listCellImage");
        mTextLabel.getStyleClass().add("listCellText");
        AnchorPane.setLeftAnchor(imageHolder, 10.0);
        AnchorPane.setTopAnchor(imageHolder, 10.0);
        AnchorPane.setBottomAnchor(imageHolder, 10.0);
        AnchorPane.setLeftAnchor(mTextLabel, 80.0);
        AnchorPane.setRightAnchor(mTextLabel, 1.0);
        AnchorPane.setTopAnchor(mTextLabel, 0.0);
        AnchorPane.setBottomAnchor(mTextLabel, 0.0);
        colourStrip = new VBox(); …
Run Code Online (Sandbox Code Playgroud)

java listview javafx

4
推荐指数
1
解决办法
4406
查看次数

标签 统计

java ×1

javafx ×1

listview ×1