Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does layout_height="0dp" mean? [duplicate]

I looked at lot of places where layout_height="0dp" used. Can someone tell me what does it mean? I tried looking at android developer docs and did not find relevant information there.

Thanks.

like image 306
user862268 Avatar asked Aug 07 '11 20:08

user862268


People also ask

What does 0dp mean in Android?

Equal distribution. To create a linear layout in which each child uses the same amount of space on the screen, set the android:layout_height of each view to "0dp" (for a vertical layout) or the android:layout_width of each view to "0dp" (for a horizontal layout).

What does 0dp mean in constraint layout?

for the children of ConstraintLayout if you have set constraints then the 0dp is for match_constraint (take full width, or full height) Using 0dp, which is the equivalent of "MATCH_CONSTRAINT" https://developer.android.com/reference/android/support/constraint/ConstraintLayout.

What is layout_ weight in android?

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.

Is a view group that aligns all children in a single direction vertically or horizontally?

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


1 Answers

Well, height or width when set to "0dp", are mostly used in combination with "weight". e.g. you want to fill all the available space for height:

android:layout_height = "0dp"
android:layout_weight = "1.0"
like image 189
Khawar Avatar answered Sep 20 '22 23:09

Khawar