Difference between fill_parent and wrap_content ?
Ans-
Ans-
fill_parent
(deprecated and renamed MATCH_PARENT
in API Level 8 and higher)
Setting the layout of a widget to fill_parent will force it to expand to take up as much space as is available within the layout element it's been placed in. It's roughly equivalent of setting the dockstyle of a Windows Form Control to
Fill
.
Setting a top level layout or control to fill_parent will force it to take up the whole screen.
wrap_content
Setting a View's size to wrap_content will force it to expand only far enough to contain the values (or child controls) it contains. For controls -- like text boxes (TextView) or images (ImageView) -- this will wrap the text or image being shown. For layout elements it will resize the layout to fit the controls / layouts added as its children.
FILL_PARENT
(renamed MATCH_PARENT in API Level 8 and higher), which means that the View wants to be as big as its parent (minus padding)WRAP_CONTENT
, which means that the View wants to be just big enough to enclose its content (plus padding)
what is android:layout_weight
Ans- With
layout_weight
you can specify a size ratio between multiple views. E.g. you have a MapView
and a table
which should show some additional information to the map. The map should use 3/4 of the screen and table should use 1/4 of the screen. Then you will set the layout_weight
of the map
to 3 and the layout_weight
of the table to 1.
To get it work you also have to set the height or width (depending on your orientation) to 0px.