Keeping the aspect ratio on different screen sizes

I read many threads about this, but i didn’t find any answers that would work for me.

I am making a scrolling 2d game for android phones, so the width should scale up/down, depending on the phone’s display, the length doesnt really matter if it gets cut of in the meantime.

How am I to make it scale up/down the width depending on the displays width?
(I new to programming so i would appreciate a working code or a “simple code for dummies” explaining)

Thank you!

When you say “the length doesn’t matter if it gets cut off”, that sounds like you don’t want to keep the aspect ratio. In which case you don’t need to do anything.

–Eric