Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between android:orientation="vertical" vs android:orientation="horizontal"

I was wondering what the difference are between these two? benefits of one over the other? etc...

like image 325
thunderousNinja Avatar asked May 24 '11 21:05

thunderousNinja


People also ask

What is the difference between horizontal and vertical layout?

Horizontal lines, as we know, follow the horizon, so they go straight across. Vertical lines go up and down. As this works with other elements to bring an image together, you either get a horizontal image or a vertical one.

Which layout allows us to place components automatically in vertical or horizontal position?

LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally. You can specify the layout direction with the android:orientation attribute.

What is the default orientation of linear layout?

Linear Layout You can specify whether that line is horizontal or vertical by using the android:orientation attribute. By default, orientation is horizontal. Horizontal orientation will only have one single row of elements on the screen and in the case of vertical orientation, it will only have one child per row.

What is android Layout_weight?

In a nutshell, layout_weight specifies how much of the extra space in the layout to be allocated to the View. LinearLayout supports assigning a weight to individual children. This attribute assigns an "importance" value to a view, and allows it to expand to fill any remaining space in the parent view.


3 Answers

"horizontal" allows your elements within the Layout to be placed beside each other where as "vertical" will stack them. There aren't really benefits to either - use the one that best fits your design.

The official documentation says: "Should the layout be a column or a row? Use "horizontal" for a row, "vertical" for a column."

like image 82
Haphazard Avatar answered Oct 23 '22 04:10

Haphazard


As far as I know they are only relevant for the LinearLayout. And it determines wither your views get stacked vertically like this:

View1

View2

View3

View4

etc...

or horizontally like this:

View1 View2 View3 View4 etc...
like image 24
FoamyGuy Avatar answered Oct 23 '22 03:10

FoamyGuy


horizontal:

# # # # # # # # # # # 

vertical:

#
#
#
#
#
#
#
#
like image 7
x4u Avatar answered Oct 23 '22 03:10

x4u