在ExtJS中,当我滚动浏览器窗口时,Ext.window.window保持在Viewport上的相同位置。我想把这个窗口固定在它的绝对位置上 我看到文档说:
fixed:布尔值 配置为true以将此Component固定在浏览器视口中的X,Y坐标处,不受滚动文档的影响。
默认为:false
但对我不起作用。我错过了什么?如何修复窗口的绝对位置,不要滚动浏览器滚动?
答案 0 :(得分:1)
这部分有效。但是,你还担心约束吗?
package com.boontaran.games.SICT;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Handler;
import android.os.CountDownTimer;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.boontaran.MessageEvent;
public class LevelQuizDialog extends Group {
public static final int ON_CLOSE = 1;
public static final int ON_OPEN = 2;
public static final int LevelCompleted2 = 1;
public static final int LevelFailed2 = 2;
//private Timer timer;
public LevelQuizDialog( int score) {
// final int score2 = score;
NinePatch patch = new NinePatch(SICT.atlas.findRegion("dialog_bg"),60,60,60,60);
Image bg = new Image(patch);
bg.setSize(980, 670);
setSize(bg.getWidth() , bg.getHeight());
addActor(bg);
final Image title = new Image(SICT.atlas.findRegion("quiz"));
addActor(title);
title.setX((getWidth() - title.getWidth())/2);
title.setY(getHeight() - title.getHeight() - 100);
final Image title2 = new Image(SICT.atlas.findRegion("level_completed"));
//addActor(title2);
title2.setX((getWidth() - title2.getWidth())/2);
title2.setY(getHeight() - title2.getHeight() - 100);
final Image title3 = new Image(SICT.atlas.findRegion("level_failed"));
// addActor(title3);
title3.setX((getWidth() - title3.getWidth())/2);
title3.setY(getHeight() - title3.getHeight() - 100);
Image image2 = new Image(SICT.atlas.findRegion("border"));
image2.setSize(300,120);
addActor(image2);
image2.setPosition(390,300);
//score label
LabelStyle style = new LabelStyle();
style.font = SICT.font1;
style.fontColor = new Color(0x624601ff);
Label label = new Label("Score :", style);
addActor(label);
label.setPosition(590, 600);
LabelStyle style2 = new LabelStyle();
style2.font = SICT.font2;
style2.fontColor = new Color(0x624601ff);
//the score
Label scoreLabel = new Label(String.valueOf(score) , style2);
addActor(scoreLabel);
scoreLabel.setPosition(800, 600);
//Label array1 = new Label("", array1); and the checking
Random random = new Random();
int array = random.nextInt(10) + 1;
int array2 = random.nextInt(10) +1;
final int answer = random.nextInt(20) +5;
final int checker = array + array2;
Label StringArray = new Label(String.valueOf(array), style2);
addActor(StringArray);
StringArray.setPosition(417,325);
Label StringArray2 = new Label(String.valueOf(array2), style2);
addActor(StringArray2);
StringArray2.setPosition(520, 325);
Label StringArray3 = new Label(String.valueOf(answer), style2);
addActor(StringArray3);
StringArray3.setPosition(620, 325);
//timer
//setPosition(20, 600);
final ImageButton CheckBtn = new ImageButton(
new TextureRegionDrawable(SICT.atlas.findRegion("check1")),
new TextureRegionDrawable(SICT.atlas.findRegion("check2")));
addActor(CheckBtn);
//CheckBtn.setSize(120, 120);
CheckBtn.setX(400);
CheckBtn.setY(70);
final ImageButton WrongBtn = new ImageButton(
new TextureRegionDrawable(SICT.atlas.findRegion("wrong1")),
new TextureRegionDrawable(SICT.atlas.findRegion("wrong2")));
addActor(WrongBtn);
//WrongBtn.setSize(120, 120);
WrongBtn.setX(550);
WrongBtn.setY(70);
CheckBtn.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
WrongBtn.clearListeners();
if(checker == answer )
{
removeActor(title);
addActor(title2);
}
if(checker != answer)
{
removeActor(title);
addActor(title3);
}
}
});
//fire event on button click
WrongBtn.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
CheckBtn.clearListeners();
if(checker != answer )
{
removeActor(title);
addActor(title2);
}
if(checker == answer)
{
removeActor(title);
addActor(title3);
}
new CountDownTimer(4000, 4000) {
public void onTick(long millisUntilFinished) {
}
public void onFinish() {
fire(new MessageEvent(ON_CLOSE));
}
}.start();
}
});
}
答案 1 :(得分:0)
喜欢这样:
DEVELOPMENT