Jump to content

Redimensionar imagem

Recommended Posts



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



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;
public void draw(Canvas 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

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.