How to differentiate Android wrap_content from fill_parent
In Android, do I always confuse "wrap_content" or "fill_parent" component attributes "layout_width" and "layout_height?
Let's take a look at the following definition:
Wrap_content-the component only needs to display content large enough to enclose it.
Fill_parent-fill in the remaining space if the component is to be displayed as large. (Renamed match_parent at API Level 8)
Let's take a look at the following demo:
1. Wrap_content
A button component that sets "wrap_content" in the width and height attributes. It tells Android that the display button is large enough to put its content "button ABC" only.
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent">
Image.png
2. Fill_parent-Width
If you change "layout_width" "fill_parent", the button width will fill in the remaining space, because the height of the button "as big as relative layout" is still enough to put its content.
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent">
Image.png
3. fill_parent-height
If you change "layout_height" "fill_parent", the height of the button will fill the remaining space, because the width of the button "as big as relative layout" is still enough to put its content.
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent">
Image.png
4. Fill_parent-width and height
The "layout_width" and "layout_height" "fill_parent" buttons are displayed as large as the screen of the entire device. They only fill up the entire screen space.
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent">
Image.png
Original blog address: http://www.apkbus.com/blog-919651-76525.html
In fact, you can specify an exact width and height, but this is not recommended because of the various screen sizes of Android devices. You just don't know what size Android devices are running on your fantasy app.