Layout for all screen sizes

Asked

Viewed 2,056 times

2

I just started messing with android and I came up with a big question. How I make a layout to work in all screen sizes?

From what I’ve searched, there are specific layout folders for each size. So, how I create these folders, since in Android Studio comes only with a folder "layout".

Another question, done this, how my app will know which layout to open?

3 answers

1


Just create the folders on the same level as the layout and create the file inside with the same name. Android takes care of checking which size of the screen and takes the layout in the corresponding folder.

Your job is to just write the layout files for each dimension and put them in the right folders

Same goes for the briefcase drawable

1

Hello. I recommend you take a look at this google article first: Supporting Multiple screen Sizes. I’m sure that after reading all this tutorial (you can even google translate) you will not have any doubts.

Basically you have to resize your images to pre-defined sizes by Google. Android, underneath the scenes, chooses the ideal size automatically based on your phone’s screen!

0

Is there any default for folder names? So the following code is unnecessary? For it was the only way I had found for the solution of my problem

if (config.screenWidthDp  == 720) {
            setContentView(R.layout.layout_720x1280);
 }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.