I need help cant figure this by myself how to change ScrollPane width in libgdx ? because now its the size as I upload it and I need it to be on all sizes the same width.
You need to put container inside ScrollPane (Table for example) and setup required size:
Table contentRoot = new Table();
ScrollPane scrollPane = new ScrollPane(contentRoot);
scrollPane.setSize(width, height);
You need to add uploaded content to container (contentRoot). In this case ScrollPane will save size and scroll bars will be automatically enabled:
contentRoot.add(uploadedContent).row();
Related
I'm working on an AIR desktop project.
I have a scrollPane with a container assigned to it...
mainScrollPane.source = mainContainer;
The scrollPane is resized whenever the window is resized, in order to keep things fluid (it fits under a header container, and to the right of a left container)...
mainScrollPane.setSize(Math.round(stageWidth - leftContainer.width), Math.round(stageHeight - headerContainer.height));
mainScrollPane.source = mainContainer;
I'm dynamically creating movieclips and adding each one to the container...
mainContainer.addChild(boxMC);
In my library, boxMC is set to 400 pixels wide, yet I'm finding that each boxMC is displayed much wider than that.
When I resize the window, each boxMC doesn't scale in size (good).
I'm clearly not understanding the process for creating a fluid scrollPane that can be resized while having it's contents remain the size that I've created them at in the library. Can sometime please enlighten me?
Thank you.
The solution was not to give mainContainer width and height settings. So instead of mainContainer.graphics.drawRect(0,0,100,100); mainContainer.width = 500; mainContainer.height = 200; I just made it mainContainer.graphics.drawRect(0,0,100,100); then added movieclip don't scale their size when mainScrollPane is resized.
I try to create a selectbox that adapts its width to its content. The JavaDoc states: The preferred size of the select box is determined by the maximum text bounds of the items and the size of the SelectBox.SelectBoxStyle.background., so it should happen automatically.
If I add the selectbox it doesn't show any content and has only the minimal size of the 9Patch used for the background. The text is only visible if I set the width manually.
Do I have to enable this functionality somehow?
I solved it.
After adding the items you have to call pack()
SelectBox<String> sb = new SelectBox<>(skin);
sb.setItems("Hello World", "FooBarBaz", "FizzBuzz");
sb.pack();
stage.addActor(sb);
I am having problem setting the stage height and width for the app i am developing.
I need to set the height and width as for the screen of the device it is on. So i do stage.fullScreenHeight and stage.fullScreenWidth.
But i just realized that the fullScreenHeight and width it is setting is the size for the stage inside flash pro cc under properties(the stage size).
And i am not able to make the stage width and height according to the phone's. Even if i do Capabilities.screenResolutionX; or stage.stageHeight. All of them set to either the size of the image, or the stage inside flash pro, but none is according to the device.
Edit:
E.g. var button = Button = new Button();
button.width = stage.stageWidth;
button.height = Button.width/stage.stageWidth * Button.height;
Try stage.scaleMode = StageScaleMode.NO_SCALE
or unchecking "full screen" checkbox in your Air settings
How to fix a text field width and height as well as its position when air window re-size in flash action script with air?
I am trying to use text field like as notepad editor area but when when i re-size adobe air window the text field property automatically adjust ,mean it change its position .
i want that when the width of air window re-size, text field should adjust its width according to adobe air window width .when the height of air re-size the text field should adjust it's height according to Adobe Air window height and text field position(x,y) should fix.
For controlling resize of components, in the beginning of application configure stage:
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
Subscribe for resizing of the stage, and implement resize of TextField:
stage.addEventListener(Event.RESIZE, onResize);
function onResize(e:Event):void {
//Implement logic, screen size is (stage.stageWidth x stage.stageHeight)
const padding: int = 20;
myTextField.width = stage.stageWidth - 2*padding;
myTextField.height = stage.stageHeight - 2*padding;
}
I'm new to flex and I have a question concerning bitmapData and its width and height.
Normally you set up bitmapData like this in AS3:
var bd:BitmapData = new BitmapData(100, 100, true, 0x00000000);
var bm:Bitmap = new Bitmap(bd);
But in Flex embedding an an image works like this:
[Embed(source="../../../../../assets/sprites/asteroids/asteroid_32_full.gif")]
public static const Asteroid1:Class;
var imageBM:Bitmap = new Library.Asteroid1();
When using the bitmapData (e.g. imageBM.bitmapData) I don't have to set up width and height any more. Does the Flash player know the width and height of a bitmapData automatically even when NOT setting up the bitmapData's width and height? I'm totally unaware about this topic because I don't know whether the Flash player always knows the dimensions of a bitmapData. Could this cause problems when not setting up the dimensions of a bitmapData?
If you're generating a BitmapData object from scratch, you have to set the width and height.
If it's being generated automatically via image import, you don't. It's set under the covers by the image import process.