java.lang.Object | |||
↳ | android.graphics.drawable.Drawable | ||
↳ | android.graphics.drawable.LayerDrawable | ||
↳ | android.graphics.drawable.TransitionDrawable |
An extension of LayerDrawables that is intended to cross-fade between
the first and second layer. To start the transition, call startTransition(int)
. To
display just the first layer, call resetTransition()
.
It can be defined in an XML file with the <transition>
element.
Each Drawable in the transition is defined in a nested <item>
. For more
information, see the guide to Drawable Resources.
XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
android:bottom | Bottom coordinate of the layer. | ||||||||||
android:drawable | Drawable used to render the layer. | ||||||||||
android:id | Identifier of the layer. | ||||||||||
android:left | Left coordinate of the layer. | ||||||||||
android:right | Right coordinate of the layer. | ||||||||||
android:top | Top coordinate of the layer. |
[Expand]
Inherited XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.graphics.drawable.LayerDrawable
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a new transition drawable with the specified list of layers.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Draw in its bounds (set via setBounds) respecting optional effects such
as alpha (set via setAlpha) and color filter (set via setColorFilter).
| |||||||||||
Indicates whether the cross fade is enabled for this transition.
| |||||||||||
Show only the first layer.
| |||||||||||
Reverses the transition, picking up where the transition currently is.
| |||||||||||
Enables or disables the cross fade of the drawables.
| |||||||||||
Begin the second layer on top of the first layer.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.graphics.drawable.LayerDrawable
| |||||||||||
From class
android.graphics.drawable.Drawable
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
android.graphics.drawable.Drawable.Callback
|
Bottom coordinate of the layer.
Must 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), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol bottom
.
Drawable used to render the layer.
Must be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
This corresponds to the global attribute
resource symbol drawable
.
Identifier of the layer. This can be used to retrieve the layer from a drawbable container.
Must be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
This corresponds to the global attribute
resource symbol id
.
Left coordinate of the layer.
Must 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), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol left
.
Right coordinate of the layer.
Must 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), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol right
.
Top coordinate of the layer.
Must 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), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol top
.
Create a new transition drawable with the specified list of layers. At least 2 layers are required for this drawable to work properly.
Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha) and color filter (set via setColorFilter).
canvas | The canvas to draw into |
---|
Indicates whether the cross fade is enabled for this transition.
Reverses the transition, picking up where the transition currently is. If the transition is not currently running, this will start the transition with the specified duration. If the transition is already running, the last known duration will be used.
duration | The duration to use if no transition is running. |
---|
Enables or disables the cross fade of the drawables. When cross fade is disabled, the first drawable is always drawn opaque. With cross fade enabled, the first drawable is drawn with the opposite alpha of the second drawable. Cross fade is disabled by default.
enabled | True to enable cross fading, false otherwise. |
---|
Begin the second layer on top of the first layer.
durationMillis | The length of the transition in milliseconds |
---|