Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在滚动窗格中包含表格和图像的布局_Java_Libgdx - Fatal编程技术网

Java 在滚动窗格中包含表格和图像的布局

Java 在滚动窗格中包含表格和图像的布局,java,libgdx,Java,Libgdx,我想要一个简单的布局,在滚动窗格的顶部有一个图像(里面有一个表)。 滚动窗格工作得很好,但问题是图像的比例错误(我的图像内部有一个圆圈,它变成椭圆形) 代码如下: batch = new SpriteBatch(); stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); Skin skin = new Skin(Gdx.files.internal("ui/uiskin.jso

我想要一个简单的布局,在滚动窗格的顶部有一个图像(里面有一个表)。 滚动窗格工作得很好,但问题是图像的比例错误(我的图像内部有一个圆圈,它变成椭圆形)

代码如下:

   batch = new SpriteBatch();
   stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);

   Skin skin = new Skin(Gdx.files.internal("ui/uiskin.json"));
   Texture textureButton = new Texture(Gdx.files.internal("image.png"));
   Image imageButton1 = new Image(textureButton);
   Image imageButton2 = new Image(textureButton);

   Table t = new Table();
   for (int i = 0; i < 30; i++) {
      t.row();
      t.add(new Label("TEST TEST TEST TEST TEST TEST TEST" + i, skin));
   }
   ScrollPane scrollPane = new ScrollPane(t);

   Table container = new Table();
   container.setFillParent(true);
   container.row().expand();
   container.add(imageButton1);
   container.row();
   container.add(scrollPane);
   container.layout();
   container.debug();

   stage.addActor(container);
batch=new SpriteBatch();
stage=newstage(Gdx.graphics.getWidth(),Gdx.graphics.getHeight(),false);
皮肤=新皮肤(Gdx.files.internal(“ui/uiskin.json”);
纹理按钮=新纹理(Gdx.files.internal(“image.png”);
Image imageButton1=新图像(纹理按钮);
图像imageButton2=新图像(纹理按钮);
表t=新表();
对于(int i=0;i<30;i++){
t、 行();
t、 添加(新标签(“测试”+i,皮肤));
}
滚动窗格滚动窗格=新滚动窗格(t);
表容器=新表();
container.setFillParent(true);
container.row().expand();
容器。添加(imageButton1);
container.row();
container.add(滚动窗格);
container.layout();
container.debug();
stage.addActor(容器);
我完全迷路了:(

提前感谢您的帮助!

此:

stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
将其更改为true:

stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);

如果为假:

舞台将拉伸到视口,可能会拉伸舞台的纵横比

感谢NateS(来自Badlogic游戏论坛),解决方案是为图像设置最小宽度:

table.add(image).minSize(Value.prefWidth, Value.prefHeight);

感谢您的回答,但将false更改为true不会改变任何事情:(