0

Hi is it possible that in my android application buttons which are there in vertical orienatation change to tabs in horizontal orientation . So they can fit better for tablets ?

  • 3
    why not use separate layout for tablets? or do you want to put it horizontally? – Androyds Sep 12 '13 at 06:48
  • [Yes it's possible.](http://stackoverflow.com/questions/17661516/different-widgets-views-for-different-screen-orientations) – Hardik Joshi Sep 12 '13 at 06:49
  • you can check this [link](http://stackoverflow.com/a/17440739/1758960) for more details about layout for tablets – Gru Sep 12 '13 at 06:53

4 Answers4

3

one way is to create 2 folders called layout-land and layout-port, write 2 different xml's with same name and put them in layout-land and layout-port

for example if you have a home.xml

If you put home.xml in layout-port folder, when your device is in portrait orientation it will use the file: layout-port/home.xml.

If you put home.xml in layout-land folder, when your device in landscape orientation it will use the file: layout-land/home.xml.
Beginner
  • 1,414
  • 2
  • 21
  • 41
1

You have to create separate XML files for portrait and landscape modes and place it in different directories. The device will automatically select the right one. You can use the following directory structure

res/layout/my_layout.xml   
res/layout-land/my_layout.xml

For more details read this doc.

Shruti
  • 1
  • 13
  • 55
  • 95
0

Yes, it's definitely possible.

Have you check this one? Basically it's using the Resources in your Android project. You can create the following folders:

res/layout/           //portrait
res/layout-land/      //landscape

Have a layout with the same name but different content depending on what you want.

Community
  • 1
  • 1
princepiero
  • 1,287
  • 3
  • 15
  • 28
0

for 7 inch tablet:-make a new folder in res/layout-sw600dp-port for portrait mode and res/layout-sw600dp-land for landscape mode

for 10 inch tablet:-make a new folder in res/layout-sw720dp-port for portrait mode and res/layout-sw720dp-land for landscape mode

for phone layout upto 5 inch screen,just design your screen in layout folder

hope this will help you !!Happy Coding!!

Pankaj Arora
  • 10,224
  • 2
  • 37
  • 59