Create your account

Already have an account? Login here

Create account

29. Weights in Linear Layout

Design + Code an Android App from Scratch

Woah, wait a second..

Scrounge up some loose change to become a pro member, or login to your account to view this lesson.

Alright, join now. Or login to your account if you're already a pro member.

This video shows you how you can size the Views inside the LinearLayout by specifying 2 special values. The match_parent value indicates that the View should take up all the available width inside the ViewGroup in which it is currently placed. The wrap_content value indicates that the View should take up only the amount of space it requires to display the content inside it or no space if the View has no content which is applicable to certain Views. Weights let you control the ratio of space taken by Views with respect to each other. In a horizontal LinearLayout, weights control how much percentage of the screen width is occupied by each View when we specify a layout weight for that View. A value of 1 for every View indicates that all Views take up equal space inside the LinearLayout. In a vertical LinearLayout, weights control how much percentage of the screen height is occupied by each View when we specify a layout weight for that View

Course Cirriculum