and
and

Reputation: 351

should I design a layout for all the devices in android studio1.3.1

Android studio 1.3.1 has many devices and sizes for phones and tablets. should I design layout for all the devices in android studio1.3.1? Please see the following image and consider there are not questions about my question.

1- which folders I should create really for supporting a layout in all devices?

2- If I used a @+id/button for a button in a activity_main layout, should I use the same @+id/button for the same activity_main layout in other folder for supporting?

enter image description here

Upvotes: 3

Views: 96

Answers (2)

Henrik Wassdahl
Henrik Wassdahl

Reputation: 1140

  1. You probably don't need to design separate designs for all resolutions. I'd say it depends on what you want to design. Sometimes maybe phone and sw-600 would be enough. Sometimes you you might want to design for phone portrait mode too.

Check out this course on Udacity made by Google if you want more tips: Android Design for Developers Especially lesson 5 about adaptive design.

  1. You should use the same id. And in the Java code you can specify what a button should do depending on what layout that has been loaded. For example, if you loaded the tablet layout maybe a container that you specified will be available. But if you loaded the phone layout the container would be null.

Upvotes: 1

Behzad Bahmanyar
Behzad Bahmanyar

Reputation: 6305

For the first Question:

No. You don't have to make a layout for every device configuration and most of it will handled by android if you use "dp" for all views and widgets and "sp" for fonts but if the layout is not shown correctly in some devices, you just have to alter layout for those device configs.

Here is some of the best practices for android layout compatibility:

  • always define views dimensions in dimens.xml

  • always use "dp" for defining views size and "sp" for font size

  • always first try solve layout incompatibility by defining new config for dimens.xml unless the design need to be changed then use new config for layout

    also google have good documentation about this : Supporting Multiple Screens

Second Question: Yes. you should define the widget again in new layout.

Upvotes: 2

Related Questions