0

Came up with this question. Could someone explain this?

Q. Suppose a layout file declares a LinearLayout called LL that contains two child Views, View1 and View2. In the layout file View1 is given an android:layout_weight of 2 and a layout_width of 0dp. View 2 is given an android:layout_weight of 3 and a layout_width of 0dp. In this example, which of the following statements must be true?

(a) View 2 takes up 3/5 of LL's width.

(b) View 1 takes up 2/5 of the display's width.

(c) View 2 takes up 2/3 of the display's width.

(d) View 1 takes up 2/3 of LL's width.

According to solutions (a) is correct. could someone explain?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Kebrum Otis
  • 25
  • 1
  • 6

1 Answers1

0

Both views have a combined weight total of 5. So View 1 will take up 2/5 of the LL and view 2 will take up 3/5 of the LL. The display width is irrelevant.

Just The Highlights
  • 1,555
  • 19
  • 31