Stay organized with collections
Save and categorize content based on your preferences.
Placeholder
public
class
Placeholder
extends View
java.lang.Object
|
↳ |
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
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 |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
Public constructors
Placeholder
public Placeholder (Context context)
Parameters |
context |
Context |
Placeholder
public Placeholder (Context context,
AttributeSet attrs)
Parameters |
context |
Context |
attrs |
AttributeSet |
Placeholder
public Placeholder (Context context,
AttributeSet attrs,
int defStyleAttr)
Parameters |
context |
Context |
attrs |
AttributeSet |
defStyleAttr |
int |
Placeholder
public Placeholder (Context context,
AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
Parameters |
context |
Context |
attrs |
AttributeSet |
defStyleAttr |
int |
defStyleRes |
int |
Public methods
getContent
public View getContent ()
Returns the content view
Returns |
View |
null if no content is set, otherwise the content view
|
getEmptyVisibility
public 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
public 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
public 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
|
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# Placeholder\n\nSummary: [Ctors](#pubctors) \\| [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nPlaceholder\n===========\n\n| This package is part of the Android [support library](/topic/libraries/support-library) which is no longer maintained. The Constraint Layout support library has been superseded by the [AndroidX Constraint\n| Layout library](/reference/androidx/constraintlayout/classes), which is part of [Jetpack](/jetpack). The `Placeholder` class has been superseded by [`androidx.constraintlayout.widget.Placeholder`](/reference/androidx/constraintlayout/widget/Placeholder). We recommend using the AndroidX libraries in all new projects. You should also consider [migrating](/jetpack/androidx/migrate) existing projects to AndroidX.\n\n\n`\npublic\n\n\nclass\nPlaceholder\n`\n\n\n`\n\n\n`\n\n`\n\nextends View\n\n\n`\n\n`\n\n\n`\n\n|---|---|----------------------------------------|\n| java.lang.Object |||\n| ↳ | View ||\n| | ↳ | android.support.constraint.Placeholder |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\n**Added in 1.1**\n\n\nA `Placeholder` provides a virtual object which can position an existing object.\n\n\nWhen the id of another view is set on a placeholder (using `setContent()`),\nthe placeholder effectively becomes the content view. If the content view exist on the\nscreen it is treated as gone from its original location.\n\n\nThe content view is positioned using the layout of the parameters of the `Placeholder` (the `Placeholder`\nis simply constrained in the layout like any other view).\n\n\u003cbr /\u003e\n\nSummary\n-------\n\n| ### Public constructors ||\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| ` `[Placeholder](/reference/android/support/constraint/Placeholder#Placeholder(Context))`(Context context) ` |\n| ` `[Placeholder](/reference/android/support/constraint/Placeholder#Placeholder(Context,%20AttributeSet))`(Context context, AttributeSet attrs) ` |\n| ` `[Placeholder](/reference/android/support/constraint/Placeholder#Placeholder(Context,%20AttributeSet,%20int))`(Context context, AttributeSet attrs, int defStyleAttr) ` |\n| ` `[Placeholder](/reference/android/support/constraint/Placeholder#Placeholder(Context,%20AttributeSet,%20int,%20int))`(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) ` |\n\n| ### Public methods ||\n|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` View` | ` `[getContent](/reference/android/support/constraint/Placeholder#getContent())`() ` Returns the content view |\n| ` int` | ` `[getEmptyVisibility](/reference/android/support/constraint/Placeholder#getEmptyVisibility())`() ` Returns the behaviour of a placeholder when it contains no view. |\n| ` void` | ` `[setContentId](/reference/android/support/constraint/Placeholder#setContentId(int))`(int id) ` Sets the content view id |\n| ` void` | ` `[setEmptyVisibility](/reference/android/support/constraint/Placeholder#setEmptyVisibility(int))`(int visibility) ` Sets the visibility of placeholder when not containing objects typically gone or invisible. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From class ` java.lang.Object ` |-------------------|-------------------------------| | ` Object` | ` clone() ` | | ` boolean` | ` equals(Object arg0) ` | | ` void` | ` finalize() ` | | ` final Class\u003c?\u003e` | ` getClass() ` | | ` int` | ` hashCode() ` | | ` final void` | ` notify() ` | | ` final void` | ` notifyAll() ` | | ` String` | ` toString() ` | | ` final void` | ` wait(long arg0, int arg1) ` | | ` final void` | ` wait(long arg0) ` | | ` final void` | ` wait() ` | ||\n\nPublic constructors\n-------------------\n\n### Placeholder\n\n```\npublic Placeholder (Context context)\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----------|------------------|\n| `context` | `Context` \u003cbr /\u003e |\n\n### Placeholder\n\n```\npublic Placeholder (Context context, \n AttributeSet attrs)\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----------|-----------------------|\n| `context` | `Context` \u003cbr /\u003e |\n| `attrs` | `AttributeSet` \u003cbr /\u003e |\n\n### Placeholder\n\n```\npublic Placeholder (Context context, \n AttributeSet attrs, \n int defStyleAttr)\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|----------------|-----------------------|\n| `context` | `Context` \u003cbr /\u003e |\n| `attrs` | `AttributeSet` \u003cbr /\u003e |\n| `defStyleAttr` | `int` \u003cbr /\u003e |\n\n### Placeholder\n\n```\npublic Placeholder (Context context, \n AttributeSet attrs, \n int defStyleAttr, \n int defStyleRes)\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|----------------|-----------------------|\n| `context` | `Context` \u003cbr /\u003e |\n| `attrs` | `AttributeSet` \u003cbr /\u003e |\n| `defStyleAttr` | `int` \u003cbr /\u003e |\n| `defStyleRes` | `int` \u003cbr /\u003e |\n\nPublic methods\n--------------\n\n### getContent\n\n```\npublic View getContent ()\n```\n\nReturns the content view\n\n\u003cbr /\u003e\n\n| Returns ||\n|--------|----------------------------------------------------------------|\n| `View` | `null` if no content is set, otherwise the content view \u003cbr /\u003e |\n\n### getEmptyVisibility\n\n```\npublic int getEmptyVisibility ()\n```\n\nReturns the behaviour of a placeholder when it contains no view.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-------|-----------------------------------------------------------------------------|\n| `int` | Either View.VISIBLE, View.INVISIBLE, View.GONE. Default is INVISIBLE \u003cbr /\u003e |\n\n### setContentId\n\n```\npublic void setContentId (int id)\n```\n\nSets the content view id\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------|------------------------------------------------------------------------------|\n| `id` | `int`: the id of the content view we want to place in the Placeholder \u003cbr /\u003e |\n\n### setEmptyVisibility\n\n```\npublic void setEmptyVisibility (int visibility)\n```\n\nSets the visibility of placeholder when not containing objects typically gone or invisible.\nThis can be important as it affects behaviour of surrounding components.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------------|--------------------------------------------------------------|\n| `visibility` | `int`: Either View.VISIBLE, View.INVISIBLE, View.GONE \u003cbr /\u003e |"]]