What is the trick with 0dip layout_height or layouth_width?

后端 未结 3 1800
孤城傲影
孤城傲影 2020-12-05 15:00

I mean why anybody want they view to be 0dip height ? I have seen this many times, there must be some kind of trick, but I do not get it.

        

        
3条回答
  •  鱼传尺愫
    2020-12-05 15:39

    The android:layout_height="0dp" is used in various codes because:

    1. It means the height of the view can be changed later due to other layout constraints.
    2. It is a common practice and often seen in relative and linear layouts.

    e.g:

    android:layout_height = "0dp"
    android:layout_weight = "1.0"
    

    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 then use the above code and like wise the same case for width.

提交回复
热议问题