Note that there are some explanatory texts on larger screens.

plurals
  1. POslider always has default width
    primarykey
    data
    text
    <p>[UPDATE] I noticed that an invalidate() would be good but it didnt change something! So i put in the whole optionlayout with the creation of the table and the slider + labels. The backbutton is just a textbutton added to the end of the table. I know its a long code but i seems to be needed. <br></p> <p>I created a slider like this as i know that the min width of the background is used for the slider width:</p> <pre><code>public OptionScreen(MainClass game) { super(game); preference = new PreferencesHelper(); font = this.getDefaultFont(25); this.table = new Table(); if (Config.DEBUG) this.table.debug(); // add volumenlabel LabelStyle style = new LabelStyle(font, Color.WHITE); volumenLabel = new Label(Config.VOLUMEN_LABLE, style); table.add(volumenLabel).colspan(2); table.row(); // add slider Skin skin = new Skin(); skin.add("sliderbackground", this.game.manager.get("data/sliderbackground.png")); skin.add("sliderknob", this.game.manager.get("data/sliderknob.png")); SliderStyle sliderStyle = new SliderStyle(); sliderStyle.background = skin.getDrawable("sliderbackground"); sliderStyle.background.setMinWidth(600f); sliderStyle.knob = skin.getDrawable("sliderknob"); volumenSlider = new Slider(0f, 1f, 0.1f, false, sliderStyle); volumenSlider.setValue(preference.getVolumen()); // load current volumen volumenSlider.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { volumeValue.setText(String.format("%.01f", volumenSlider.getValue())); // sett the preference preference.setVolumen(volumenSlider.getValue()); } }); // add volslider to stage table.add(volumenSlider); volumenLabel.invalidate(); // table style = new LabelStyle(font, Color.WHITE); // set current volumen volumeValue = new Label( String.format("%.01f", volumenSlider.getValue()), style); volumenLabel.setAlignment(2); table.add(volumeValue).width(50f); table.row(); initBackButton(); // init table table.setPosition(Config.VIRTUAL_VIEW_WIDTH / 2, Config.VIRTUAL_VIEW_HEIGHT / 2 - Config.BLOCK_SIZE * 10); // add a nice fadeIn to the whole table :) table.setColor(0, 0, 0, 0f); table.addAction(Actions.fadeIn(2f)); // alpha fade table.addAction(Actions.moveTo(Config.VIRTUAL_VIEW_WIDTH / 2, Config.VIRTUAL_VIEW_HEIGHT / 2, 2f)); // move to center of the // screen // add to stage this.stage.addActor(table); } </code></pre> <p>It's inside a table with no width or such. I already took a look if the width is sett and if the calculation for the prefWidth of the slider does take my 600. </p> <pre><code>Math.max(style.knob == null ? 0 : style.knob.getMinWidth(), style.background.getMinWidth()) </code></pre> <p>this is the calculation for the width of the slider inside the Sliderclass. If i calculate that and log it, i get the 600. <br> Everything seems to me right but the slider is way to small for the 600 i sett.<br> Background and knobtextures are 24x24.<br> So i hope you guys can tell me what i am doing wrong. <img src="https://i.stack.imgur.com/eIDbM.jpg" alt="silder"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload