What is the default layout for ImageView?

When creating in xml, the layout_width and layout_height parameters are required.
What about elements created in java code? What is their default layout?
How can I set my layout for software_fill fill_parent or wrap_content?

+4
source share
1 answer

public void addView (View child) Because: API Level 1

Adds a child view. If the layout options are not already set on the child, the default settings for this ViewGroup are set on the child. options child view item to add See Also

generateDefaultLayoutParams() 

Without additional parameters, addView(View) uses the default parameters (mainly WRAP_CONTENT ). If you look at the source code ,

 protected LayoutParams [More ...] generateDefaultLayoutParams() { if (mOrientation == HORIZONTAL) { return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); } else if (mOrientation == VERTICAL) { return new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); } return null; } 
+13
source

All Articles