Jump to content
AJBM

Redimensionar imagem

Recommended Posts

AJBM

Boas!

Eu estou a fazer um jogo em android, e estou a seguir este tutorial

https://www.youtube.com/embed/GPzTSpZwFoU?feature=oembed

.

Mas estou com um problema, a imagem de fundo não se está adaptar bem ao dispositivo.


...
//tamanho da imagem
public static final int WIDTH = 594;
public static final int HEIGHT = 274;
....
@Override
public void draw(Canvas canvas) {
	super.draw(canvas);
	if (canvas != null) {
		float scaleFactorX = getWidth() / WIDTH;
		float scaleFactorY = getHeight() / HEIGHT;
		int savedState = canvas.save();
		canvas.scale(scaleFactorX, scaleFactorY);// a imagem fica muito grande
		background.draw(canvas);
		canvas.restoreToCount(savedState);
	}
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.