Fill_parent is adopted in the Android version of the system, Match_parent is used on Android 2.2 and later. The two functions are consistent.
1) fill_parent
Active party: Parent component
Passive side: Sub-component
1. Set to Fill_parent on height or width, the height or length of the subassembly depends on the parent component's value. The usual value is equal to the parent component.
2. When the content height/width value of the subassembly is less than the parent component high/wide value, the subassembly content is stretched.
3. When the content height/width value of the subassembly is greater than the parent component high/wide value, the subassembly content is clipped.
Fill_parent set a top layout or control to make it full of screens.
2) wrap_content
Active side: Sub-component
Passive side: Parent component
1. Set to Wrap_content on height or width, the corresponding value of the parent component is determined by the contents of the child component.
2. Under the conditions allowed by the parent component high/wide value, the value depends on the content height/width value of the child component.
wrap_content layouts are automatically scaled according to the contents of the view to fit their size.
Original address: http://blog.163.com/[email protected]/blog/static/73253311201302310452516/
Translation of official documents:
1) fill_parent
Setting the layout of a component to fill_parent will force the component to expand to fill as much space as possible within the layout unit. This is roughly the same as the DockStyle property of Windows controls. Setting a top layout or control for Fill_parent will force it to fill the entire screen.
2) wrap_content
Setting the size of a view to Wrap_content will force the view to expand to show the entire content. Take the TextView and ImageView controls as an example, set to Wrap_content to fully display the text and images inside them. Layout elements will change size based on content. Setting the size of a view to Wrap_content is roughly equivalent to setting the AutoSize property of Windows controls to true.
The following explanations are more appropriate
Fill_parent set a top layout or control to make it full of screens.
Wrap_content layouts are automatically scaled according to the contents of the view to fit their size.
The following excerpt from http://blog.csdn.net/jumping_android/article/details/7397991
1. Wrap_content <?xml version= "1.0" encoding= "Utf-8"?> <relativelayout xmlns:android= "http:// Schemas.android.com/apk/res/android "android:layout_width=" fill_parent "android:layout_height=" Fill_parent "> <button android:id= "@+id/btnbutton1" android:layout_width= "Wrap_content" android:layout_he ight= "wrap_content" android:text= "button CJP"/> </RelativeLayout>
2. Fill_parent–width <?xml version= "1.0" encoding= "Utf-8"?> <relativelayout xmlns:android= "http:// Schemas.android.com/apk/res/android "android:layout_width=" fill_parent "android:layout_height=" Fill_parent "> <button android:id= "@+id/btnbutton1" android:layout_width= "Fill_parent" Android:layout_hei ght= "wrap_content" android:text= "button CJP"/> </RelativeLayout>
3. Fill_parent–height <?xml version= "1.0" encoding= "Utf-8"?> <relativelayout xmlns:android= "http:/ /schemas.android.com/apk/res/android "android:layout_width=" fill_parent "android:layout_height=" Fill_parent "> <button android:id= "@+id/btnbutton1" android:layout_width= "Wrap_content" Android:layout_ height= "fill_parent" android:text= "button CJP"/> </RelativeLayout>
4. Fill_parent–width, height <?xml version= "1.0" encoding= "Utf-8"?> <relativelayout xmlns:android= " Http://schemas.android.com/apk/res/android "android:layout_width=" fill_parent "android:layout_height=" Fill_ Parent "> <button android:id=" @+id/btnbutton1 "android:layout_width=" Fill_parent "Android oid:layout_height= "fill_parent" android:text= "button CJP"/> </RelativeLayout>