I don\'t understand how to use this attribute. Can anyone tell me more about it?
layout_weight
tells Android how to distribute your View
s in a LinearLayout
. Android then first calculates the total proportion required for all View
s that have a weight specified and places each View
according to what fraction of the screen it has specified it needs. In the following example, Android sees that the TextView
s have a layout_weight
of 0
(this is the default) and the EditText
s have a layout_weight
of 2
each, while the Button
has a weight of 1
. So Android allocates 'just enough' space to display tvUsername
and tvPassword
and then divides the remainder of the screen width into 5 equal parts, two of which are allocated to etUsername
, two to etPassword
and the last part to bLogin
:
It looks like:
and