如何将宽度与实际屏幕相匹配

时间:2014-05-16 14:01:50

标签: android eclipse

enter image description here

如何最大化我在某人教程中获得的这个程序的宽度。

这是代码:

protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    width = (w < h)?w:h;
    height = width;         //for now square mazes
    lineWidth = 1;          //for now 1 pixel wide walls
    cellWidth = (width - ((float)mazeSizeX*lineWidth)) / mazeSizeX;
    totalCellWidth = cellWidth+lineWidth;
    cellHeight = (height - ((float)mazeSizeY*lineWidth)) / mazeSizeY;
    totalCellHeight = cellHeight+lineWidth;
    gold.setTextSize(cellHeight*0.75f);
    super.onSizeChanged(w, h, oldw, oldh);

任何答案都将不胜感激!

2 个答案:

答案 0 :(得分:1)

我刚刚得到了答案:)

//new value
    height = width+(width/2);

答案 1 :(得分:0)

你可以这样试试。

int width = GraphicsDevice.DisplayMode.Width;
int height = GraphicsDevice.DisplayMode.Height;
this.graphics.PreferredBackBufferWidth = width;
this.graphics.PreferredBackBufferHeight = height;
this.graphics.IsFullScreen = true;
this.graphics.ApplyChanges();

这是问题的男人证实的答案。感谢

参考:Maximizing the width and height of the Screen

相关问题