java - 为什么我的 Libgdx ScrollPane 不水平滚动?

标签 java android libgdx

您好,我正在尝试在 libgdx 游戏中构建水平滚动屏幕,但由于某种原因只能使其垂直滚动而不是水平滚动。虽然 ScrollPane 听起来很简单,但由于某种原因我并不完全理解它,但是这里的滚动片尾示例对我有一点帮助。

我有一个表格,并向其中添加了几行文本。该表格与屏幕的大小相匹配,并且还包含一个名为 scrollerScrollPane,它填充表格的大小。我猜测,由于文本行不适合屏幕,因此 scrollerscroller 自动允许在制作人员名单示例中垂直滚动?但是,当我将文本更改为一长行文本而不是新行时,scroller 不允许我水平滚动以查看所有文本,这是为什么?文本肯定超出了scroller 宽度吗?

scrollTable = new Table();    //create table
scrollTable.add(text);    //add a long line of text bigger than screen
scrollTable.row();
scrollTable.add(text2);
scrollTable.row();
scrollTable.add(text3);
scroller = new ScrollPane(scrollTable);  //create the ScrollPane

Table table = new Table();
table.setFillParent(true);
table.add(scroller).fill().expand();
//scroller.setWidth(500);
//scroller.setScrollingDisabled(false, true);
stage.addActor(table);

private static final String reallyLongString = 
"This is a really long string that has lots of lines and repeats itself over and over again This is a really long string that has" +
" lots of lines and repeats itself over and over again This is a really long string that has lots of lines and repeats itself over and over"+
" again This is a really long string that has lots of lines and repeats itself over and over again"+
" This is a really long string that has lots of lines and repeats itself over and over again This is a really long string that has lots"+
" of lines and repeats itself over and over again";
//This is my long string of text.

最佳答案

试试这个:

Table table = new Table();
ScrollPane scroll = new ScrollPane(table);

关于java - 为什么我的 Libgdx ScrollPane 不水平滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23809849/

相关文章:

java - Maven 使用 scp 部署快照抛出 NoSuchElementException

java - 在Jmeter中,如何等待上一个采样器(JDBC请求)完成然后启动新的采样器请求(Http请求)

android - 带有 AppCompat-v7 21 的透明操作栏

android - 亚马逊上的更多应用链接

java - LibGDX Box2D RayCast fatal error

java - 如何在不按回车键的情况下向 swing.JTextField 输入数据?

java - 为什么 Eclipse Europa 经常崩溃?

android - 我在 Android 的 BroadcastReceiver 中收到的那组 SmsMessages 有什么问题?

java - libGDX html5 项目与 swarmconnect 不兼容

java - 当运行/调试特定项目时,您可以强制 Eclipse 运行/调试另一个项目吗?