0
私はプロジェクトでビューを構築するためにGridViewを使用しています。 GridViewでラベルと画像を持つアイテムを使用したいと思います。しかし、少なくとも2枚の写真を追加すると画像が重なってしまいます。なぜか分からないのですか? セルのコードは次のとおりです。ControlsFxのGridViewでセルの幅を変更する方法は?
public class AlbumCell extends GridCell<Album> {
ImageView img_cover;
Label ll_albumName;
@Override
protected void updateItem(Album item, boolean empty) {
// TODO Auto-generated method stub
super.updateItem(item, empty);
// create the view;
HBox box = new HBox();
img_cover = new ImageView();
ll_albumName = new Label();
if (empty) {
img_cover.setImage(new Image("Pic/bg.jpeg"));
ll_albumName.setText("相册名");
} else {
img_cover = new ImageView(item.getCoverUrl());
ll_albumName.setText(item.getAlbumName());
}
box.getChildren().addAll(img_cover, ll_albumName);
setGraphic(box);
}
}
を、私はこのようにFXMLでGridViewコントロールを使用する:あなたのイメージは、あなたは、単にセルの幅を設定することができ、同じ大きさのすべてとされている場合
<StackPane
GridPane.columnIndex="1" GridPane.columnSpan="3"
GridPane.rowIndex="1" GridPane.rowSpan="5">
<children>
<!-- prefHeight="309.0" prefWidth="425.0" -->
<GridView fx:id="albumsList" />
</children>
</StackPane>
の高さを使用する必要があります推測しますそれでも重複している。 –
私は理解していません:あなたはすべての画像のサイズを知っていますか?そうであれば、それぞれのサイズを含むのに十分な大きさのサイズを使用できます。 – negste
はい、サイズは限られています。私はそれがgeiときに私はイメージのサイズを変更することができると思う。やってみます。 –