lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey

Placeholder

public class Placeholder
extends View

java.lang.Object
   ↳ android.view.View
     ↳ android.support.constraint.Placeholder


Added in 1.1

A Placeholder provides a virtual object which can position an existing object.

When the id of another view is set on a placeholder (using setContent()), the placeholder effectively becomes the content view. If the content view exist on the screen it is treated as gone from its original location.

The content view is positioned using the layout of the parameters of the Placeholder (the Placeholder is simply constrained in the layout like any other view).

Summary

Inherited constants

Inherited fields

Public constructors

Placeholder(Context context)
Placeholder(Context context, AttributeSet attrs)
Placeholder(Context context, AttributeSet attrs, int defStyleAttr)
Placeholder(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Public methods

View getContent()

Returns the content view

int getEmptyVisibility()

Returns the behaviour of a placeholder when it contains no view.

void setContentId(int id)

Sets the content view id

void setEmptyVisibility(int visibility)

Sets the visibility of placeholder when not containing objects typically gone or invisible.

Inherited methods

Public constructors

Placeholder

Placeholder (Context context)

Parameters
context Context

Placeholder

Placeholder (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Placeholder

Placeholder (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

Placeholder

Placeholder (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

defStyleRes int

Public methods

getContent

View getContent ()

Returns the content view

Returns
View null if no content is set, otherwise the content view

getEmptyVisibility

int getEmptyVisibility ()

Returns the behaviour of a placeholder when it contains no view.

Returns
int Either View.VISIBLE, View.INVISIBLE, View.GONE. Default is INVISIBLE

setContentId

void setContentId (int id)

Sets the content view id

Parameters
id int: the id of the content view we want to place in the Placeholder

setEmptyVisibility

void setEmptyVisibility (int visibility)

Sets the visibility of placeholder when not containing objects typically gone or invisible. This can be important as it affects behaviour of surrounding components.

Parameters
visibility int: Either View.VISIBLE, View.INVISIBLE, View.GONE