Why android:layout_width=”0px” for fragments?

前端 未结 2 1215
心在旅途
心在旅途 2021-01-05 00:55

The layout width is always zero in fragment examples. What is behind this value?

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-05 01:47

    This has worked for me:

    1. Sum all weights in the layout. In the example that Squonk posted, there are 2 fragments and total weight is 3.

    2. The fragment ArticleListFragment has a weight=1, meaning that the size will be 1/3 ( 3 is the total weight) of the screen.

    3. The fragment ArticleReaderFragment has a weight =2, meaning that the size will be 2/3 of the screem.

    Hope it helps.

提交回复
热议问题