2016-09-05 6 views
0

次のコードを使用してScrollPaneでテーブルを作成しています。空になったときに正しく表示されますが、アイテムをテーブルに追加すると、その高さは約半分になります。LibGDX Actorを追加した後にテーブルの高さが変化する

// Init Stage & container table 
stage = new Stage(new StretchViewport(Consts.SCREEN_WIDTH, Consts.SCREEN_HEIGHT)); 
Table container = new Table(); 
stage.addActor(container); 
container.setFillParent(true); 

// Init the scrollable table 
final Table yourTurnMatches = new Table(); 
yourTurnMatches.background(Assets.getSolidColorDrawable(Color.GRAY)); 
final ScrollPane yourTurnMatchesScroll = new ScrollPane(yourTurnMatches); 
yourTurnMatchesScroll.setScrollingDisabled(true, false); 
yourTurnMatches.defaults().expand().space(4).top(); 

// Add the inner content to the container table 
container.row().top().expandX().uniform(); 
Table matchTitles = new Table(); 
matchTitles.row().expandX().uniform().padTop(10).padBottom(10); 
matchTitles.setBackground(Assets.getSolidColorDrawable(Color.DARK_GRAY)); 
matchTitles.add(txtYourTurn); 
matchTitles.add(txtTheirTurn); 
matchTitles.add(txtFinished); 
container.add(matchTitles).colspan(3).fillX(); 
container.row().top().expand().uniform().spaceLeft(5).spaceRight(5); 
container.add(yourTurnMatchesScroll).fill(); 
yourTurnMatches.row(); 

// Add button (this causes the Table height to go to about half of the original height) 
Button btn = new Button(greenButtonStyle); 
yourTurnMatches.add(btn).width(target.getWidth()*0.8f); 

私はLibGDXバージョン1.9.2を使用しています。

テーブルの高さを変更する原因は何ですか?

ありがとうございました!

答えて

0

問題を解決しました。問題が表ヘッダー行によって引き起こされたように思える:

container.row().top().expandX().uniform(); 
Table matchTitles = new Table(); 
matchTitles.row().expandX().uniform().padTop(10).padBottom(10); 
matchTitles.setBackground(Assets.getSolidColorDrawable(Color.DARK_GRAY)); 
matchTitles.add(txtYourTurn); 
matchTitles.add(txtTheirTurn); 
matchTitles.add(txtFinished); 
container.add(matchTitles).colspan(3).fillX(); 

ヘッダー行は、実際にテーブルの予約領域の半分を取ったが、後者の列は、少なくとも一つのアクターが含まれていた場合にのみ。ヘッダーのfillX()は、ヘッダーをストレッチして全体の高さに塗りつぶすことはありませんでしたが、まだスペースを予約していました。

これは私にとって本当に奇妙な動作であるように思われますが、私はまだこのような事態が発生する正当な理由を聞きたいと思います。

私の解決策は、画面全体を再設計し、ヘッダ行を省略することだったためです。

関連する問題