

In our case we have used ic_launcher image which we added in Drawable. Important Note: Make sure you have image in Drawable folder. We have used Toast to display the height and width: The output will show actual height and width the Frame Layout despite visibility is set gone. In the below code the ImageView visibility is set gone and measureAllChildren is set true. The above property has been explained below:Įxample of Frame layout having measureAllChildren attribute: Important Note: If measureallchildren is set true then it will show actual width and height of frame layout even if the views visibility is in gone state. This may also be a reference to a resource (in the form package:] type: name“) or theme attribute (in the form “? name“) containing a value of this type. We can set values in the form of Boolean i.e. The default value of measureallchildren is false. This determines whether to measure all children including gone state visibility or just those which are in the visible or invisible state of measuring visibility. Gone – The view is neither present nor visible Invisible – The view is present but not visible

Visible – the view is present and also visible This determine whether to make the view visible, invisible or gone. In the above same example of foreground we also set the foregroundGravity of FrameLayout to fill. Both the fill_horizontal and top gravity are set to framelayout. We can also set multiple values by using “|”. It is used to set the gravity of foreground. We can set values in the form of “top”, ”center_vertical”, ”fill_vertical”, ”center_horizontal”, ”fill_horizontal”, ”center”, ”fill”, ”clip_vertical”, ”clip_horizontal”, ”bottom”, ”left” or ”right”.

This defines the gravity to apply to the foreground drawable. We can set the or the color in the foreground. Important Note: On applying android:foregroud feature, all the views taken in the framelayout will goes to the background and the framelayout comes in the foreground i.e. This all are different color code model used.Įxample: In Below example of foreground we set the green color for foreground of frameLayout so the ImageView and other child views of this layout will not be shown. Possible color values can be in the form of “#rgb”, “#argb”, “#rrggbb”, or “#aarrggbb”. Foreground defines the drawable to draw over the content and this may be a color value.
