Skip to content

Most visited

Recently visited

navigation

ActivityInfo.WindowLayout

public static final class ActivityInfo.WindowLayout
extends Object

java.lang.Object
   ↳ android.content.pm.ActivityInfo.WindowLayout


Contains information about position and size of the activity on the display. Used in freeform mode to set desired position when activity is first launched. It describes how big the activity wants to be in both width and height, the minimal allowed size, and the gravity to be applied.

Summary

XML attributes

android:defaultHeight Default height of the activity. 
android:defaultWidth Default width of the activity. 
android:gravity Where to initially position the activity inside the available space. 
android:minHeight Minimal height of the activity. 
android:minWidth Minimal width of the activity. 

Fields

public final int gravity

Gravity of activity.

public final int height

Height of activity in pixels.

public final float heightFraction

Height of activity as a fraction of available display height.

public final int minHeight

Minimal height of activity in pixels to be able to display its content.

public final int minWidth

Minimal width of activity in pixels to be able to display its content.

public final int width

Width of activity in pixels.

public final float widthFraction

Width of activity as a fraction of available display width.

Public constructors

ActivityInfo.WindowLayout(int width, float widthFraction, int height, float heightFraction, int gravity, int minWidth, int minHeight)

Inherited methods

From class java.lang.Object

XML attributes

android:defaultHeight

Default height of the activity. Can be either a fixed value or fraction, in which case the height will be constructed as a fraction of the total available height.

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

May be a fractional value, which is a floating point number appended with either % or %p, such as "14.5%". The % suffix always means a percentage of the base size; the optional %p suffix provides a size relative to some parent container.

android:defaultWidth

Default width of the activity. Can be either a fixed value or fraction, in which case the width will be constructed as a fraction of the total available width.

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

May be a fractional value, which is a floating point number appended with either % or %p, such as "14.5%". The % suffix always means a percentage of the base size; the optional %p suffix provides a size relative to some parent container.

android:gravity

Where to initially position the activity inside the available space. Uses constants defined in Gravity.

Must be one or more (separated by '|') of the following constant values.

ConstantValueDescription
bottom50Push object to the bottom of its container, not changing its size.
center11Place the object in the center of its container in both the vertical and horizontal axis, not changing its size.
center_horizontal1Place object in the horizontal center of its container, not changing its size.
center_vertical10Place object in the vertical center of its container, not changing its size.
clip_horizontal8Additional option that can be set to have the left and/or right edges of the child clipped to its container's bounds. The clip will be based on the horizontal gravity: a left gravity will clip the right edge, a right gravity will clip the left edge, and neither will clip both edges.
clip_vertical80Additional option that can be set to have the top and/or bottom edges of the child clipped to its container's bounds. The clip will be based on the vertical gravity: a top gravity will clip the bottom edge, a bottom gravity will clip the top edge, and neither will clip both edges.
end800005Push object to the end of its container, not changing its size.
fill77Grow the horizontal and vertical size of the object if needed so it completely fills its container.
fill_horizontal7Grow the horizontal size of the object if needed so it completely fills its container.
fill_vertical70Grow the vertical size of the object if needed so it completely fills its container.
left3Push object to the left of its container, not changing its size.
right5Push object to the right of its container, not changing its size.
start800003Push object to the beginning of its container, not changing its size.
top30Push object to the top of its container, not changing its size.

android:minHeight

Minimal height of the activity.

NOTE: A task's root activity value is applied to all additional activities launched in the task. That is if the root activity of a task set minimal height, then the system will set the same minimal height on all other activities in the task. It will also ignore any other minimal height attributes of non-root activities.

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

android:minWidth

Minimal width of the activity.

NOTE: A task's root activity value is applied to all additional activities launched in the task. That is if the root activity of a task set minimal width, then the system will set the same minimal width on all other activities in the task. It will also ignore any other minimal width attributes of non-root activities.

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

Fields

gravity

added in API level 24
int gravity

Gravity of activity. Currently TOP, BOTTOM, LEFT and RIGHT are supported.

height

added in API level 24
int height

Height of activity in pixels.

heightFraction

added in API level 24
float heightFraction

Height of activity as a fraction of available display height. If both height and this value are set this one will be preferred.

minHeight

added in API level 24
int minHeight

Minimal height of activity in pixels to be able to display its content.

NOTE: A task's root activity value is applied to all additional activities launched in the task. That is if the root activity of a task set minimal height, then the system will set the same minimal height on all other activities in the task. It will also ignore any other minimal height attributes of non-root activities.

minWidth

added in API level 24
int minWidth

Minimal width of activity in pixels to be able to display its content.

NOTE: A task's root activity value is applied to all additional activities launched in the task. That is if the root activity of a task set minimal width, then the system will set the same minimal width on all other activities in the task. It will also ignore any other minimal width attributes of non-root activities.

width

added in API level 24
int width

Width of activity in pixels.

widthFraction

added in API level 24
float widthFraction

Width of activity as a fraction of available display width. If both width and this value are set this one will be preferred.

Public constructors

ActivityInfo.WindowLayout

added in API level 24
ActivityInfo.WindowLayout (int width, 
                float widthFraction, 
                int height, 
                float heightFraction, 
                int gravity, 
                int minWidth, 
                int minHeight)

Parameters
width int

widthFraction float

height int

heightFraction float

gravity int

minWidth int

minHeight int

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)