LibGdx resizing textures

When I run the application on desktop every texture is in right position right size, but when i run it on Andorid device
some of the textures wont show because they are out of bounds.

How can i fix the resolution that it would be the same on both devices

application runs on 1024x786 on desktop.

I want to add another question in top of that question if i may!
I have the same question than Zeta, plus, when i run on android or in another computer with another resolution, does that question of ZETA still applies?

i mean, Zeta, you use this as well :

public static void main(String[] args) {

        
        // create the listener that will receive the application events
        ApplicationListener listener = new MainView();
        
        // define the window's title
        String title = "Alpha Version";

        // define the window's size
        width = 800;
        height = 600;

        // whether to use OpenGL ES 2.0
        boolean useOpenGLES2 = true;

        // create the game
        System.setProperty("user.name", "EnglishWords");
        new LwjglApplication(listener, title, width, height, useOpenGLES2);
        
    }

    /**
     * Returns the best Size to the Screen!
     */
    public void getAvaiableScreenSize() {
    }

Right?
So we will need to worry with textures too? Or we can just adjust the camera? I think we just need to adjust the camera Zeta! I think dermetfan already helped me to mess with @resize() method…

[quote]Right?
So we will need to worry with textures too? Or we can just adjust the camera? I think we just need to adjust the camera Zeta! I think dermetfan already helped me to mess with @resize() method…
[/quote]
I’ve tried to do everything with camera just cant get it to work. I hope someone has solution for this. Or is it just better to do Android and desktop versions separately?

No, You don’t need to do anything separately. Libgdx will do that for You
Here’s a link talking about the camera and how it works:
https://code.google.com/p/libgdx/wiki/ProjectionViewportCamera

To sum it up, by default, the viewport is a rectangle -1 to +1 on both x and y. When You render Your texture at (-0.5,-0.5) with a size of 0.5, then it will be in the middle of the screen regardless of the screen. However, depending on the screen size, it might be stretched or the opposite.

not sure if im stupid. I cant still get it to work. here’s what i’ve done

	Stage stage;
	Texture backgroundTexture, titleTexture;
	Sprite background, title;
	SpriteBatch batch;
	Music bgm;
	private OrthographicCamera camera;

	@Override
	public void render(float delta) {
		camera.update();
		
		batch.begin();
		background.draw(batch);
		title.setBounds(Gdx.graphics.getWidth()/3.5f,Gdx.graphics.getHeight()/1.5f , title.getWidth(), title.getHeight());
		title.draw(batch);
		batch.end();
		
	}

	@Override
	public void resize(int width, int height) {
		float aspectRatio = (float) width / (float) height;
        camera = new OrthographicCamera(2f * aspectRatio, height);
	}

	@Override
	public void show() {
		backgroundTexture = new Texture(Gdx.files.internal("img/bgMain.jpg"));
		background = new Sprite(backgroundTexture);
		background.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
		
		titleTexture = new Texture(Gdx.files.internal("img/MenuTitle.png"));
		title = new Sprite(titleTexture);
		
		
		
		batch = new SpriteBatch();
		
		bgm = Gdx.audio.newMusic(Gdx.files.internal("music/MenuBgm.mp3"));
		bgm.setLooping(true);
		bgm.setVolume(0.5f);
		bgm.play();
		
	}

Do i have to use meshes or am i just stupid :). Just keep in mind this is my first libgdx project.

title.setBounds(Gdx.graphics.getWidth()/3.5f,Gdx.graphics.getWidth()/1.5f , title.getWidth(), title.getHeight())

I think the second argument here should be getHeight() not getWidth(). Also You don’t need to set the bounds on every frame. It should be enough to set them in the create() method;

I still have a problem keeping the aspect ratio :-. Thanks for your help thought.

How can i use pixel density in libgdx that it will resize/ scale the textures in any phone.
all i could find was getPixelDensity();. Can i use this somehow or have i undestanded pixel density completely wrong?

Thank you. (didnt want to make o new topic since its relevant to this one).