Added in API level 3
Deprecated in API level 17

SlidingDrawer


open class SlidingDrawer : ViewGroup
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ android.widget.SlidingDrawer

SlidingDrawer hides content out of the screen and allows the user to drag a handle to bring the content on screen. SlidingDrawer can be used vertically or horizontally. A special widget composed of two children views: the handle, that the users drags, and the content, attached to the handle and dragged with it. SlidingDrawer should be used as an overlay inside layouts. This means SlidingDrawer should only be used inside of a FrameLayout or a RelativeLayout for instance. The size of the SlidingDrawer defines how much space the content will occupy once slid out so SlidingDrawer should usually use match_parent for both its dimensions. Inside an XML layout, SlidingDrawer must define the id of the handle and of the content:

<SlidingDrawer
      android:id="@+id/drawer"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
 
      android:handle="@+id/handle"
      android:content="@+id/content">
 
      <ImageView
          android:id="@id/handle"
          android:layout_width="88dip"
          android:layout_height="44dip" />
 
      <GridView
          android:id="@id/content"
          android:layout_width="match_parent"
          android:layout_height="match_parent" />
 
  </SlidingDrawer>
  

Summary

Nested classes
abstract

Callback invoked when the drawer is closed.

abstract

Callback invoked when the drawer is opened.

abstract

Callback invoked when the drawer is scrolled.

XML attributes
android:allowSingleTap Indicates whether the drawer can be opened/closed by a single tap on the handle.
android:animateOnClick Indicates whether the drawer should be opened/closed with an animation when the user clicks the handle.
android:bottomOffset Extra offset for the handle at the bottom of the SlidingDrawer.
android:content Identifier for the child that represents the drawer's content.
android:handle Identifier for the child that represents the drawer's handle.
android:orientation Orientation of the SlidingDrawer.
android:topOffset Extra offset for the handle at the top of the SlidingDrawer.
Inherited XML attributes
Constants
static Int

static Int

Inherited constants
Public constructors
SlidingDrawer(context: Context!, attrs: AttributeSet!)

Creates a new SlidingDrawer from a specified set of attributes defined in XML.

SlidingDrawer(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

Creates a new SlidingDrawer from a specified set of attributes defined in XML.

SlidingDrawer(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

Creates a new SlidingDrawer from a specified set of attributes defined in XML.

Public methods
open Unit

Closes the drawer with an animation.

open Unit

Opens the drawer with an animation.

open Unit

Toggles the drawer open and close with an animation.

open Unit

Closes the drawer immediately.

open CharSequence!

open View!

Returns the content of the drawer.

open View!

Returns the handle of the drawer.

open Boolean

Indicates whether the drawer is scrolling or flinging.

open Boolean

Indicates whether the drawer is currently fully opened.

open Unit

Locks the SlidingDrawer so that touch events are ignores.

open Boolean

open Boolean

open Unit

Opens the drawer immediately.

open Unit

Sets the listener that receives a notification when the drawer becomes close.

open Unit

Sets the listener that receives a notification when the drawer becomes open.

open Unit

Sets the listener that receives a notification when the drawer starts or ends a scroll.

open Unit

Toggles the drawer open and close.

open Unit

Unlocks the SlidingDrawer so that touch events are processed.

Protected methods
open Unit

open Unit

open Unit
onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int)

open Unit
onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)

Inherited functions
Inherited properties

XML attributes

android:allowSingleTap

android:allowSingleTap
Indicates whether the drawer can be opened/closed by a single tap on the handle. (If false, the user must drag or fling, or click using the trackball, to open/close the drawer.) Default is true.

May be a boolean value, such as "true" or "false".

android:animateOnClick

android:animateOnClick
Indicates whether the drawer should be opened/closed with an animation when the user clicks the handle. Default is true.

May be a boolean value, such as "true" or "false".

android:bottomOffset

android:bottomOffset
Extra offset for the handle at the bottom of the SlidingDrawer.

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:content

android:content
Identifier for the child that represents the drawer's content.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

android:handle

android:handle
Identifier for the child that represents the drawer's handle.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

android:orientation

android:orientation
Orientation of the SlidingDrawer.

Must be one of the following constant values.

Constant Value Description
horizontal 0 Defines an horizontal widget.
vertical 1 Defines a vertical widget.

android:topOffset

android:topOffset
Extra offset for the handle at the top of the SlidingDrawer.

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).

Constants

ORIENTATION_HORIZONTAL

Added in API level 3
static val ORIENTATION_HORIZONTAL: Int

Deprecated: Deprecated in Java.

Value: 0

ORIENTATION_VERTICAL

Added in API level 3
static val ORIENTATION_VERTICAL: Int

Deprecated: Deprecated in Java.

Value: 1

Public constructors

SlidingDrawer

Added in API level 3
SlidingDrawer(
    context: Context!,
    attrs: AttributeSet!)

Creates a new SlidingDrawer from a specified set of attributes defined in XML.

Parameters
context Context!: The application's environment.
attrs AttributeSet!: The attributes defined in XML.

SlidingDrawer

Added in API level 3
SlidingDrawer(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int)

Creates a new SlidingDrawer from a specified set of attributes defined in XML.

Parameters
context Context!: The application's environment.
attrs AttributeSet!: The attributes defined in XML.
defStyleAttr Int: An attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults.

SlidingDrawer

Added in API level 21
SlidingDrawer(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int,
    defStyleRes: Int)

Creates a new SlidingDrawer from a specified set of attributes defined in XML.

Parameters
context Context!: The application's environment.
attrs AttributeSet!: The attributes defined in XML.
defStyleAttr Int: An attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults.
defStyleRes Int: A resource identifier of a style resource that supplies default values for the view, used only if defStyleAttr is 0 or can not be found in the theme. Can be 0 to not look for defaults.

Public methods

animateClose

Added in API level 3
open fun animateClose(): Unit

Deprecated: Deprecated in Java.

Closes the drawer with an animation.

animateOpen

Added in API level 3
open fun animateOpen(): Unit

Deprecated: Deprecated in Java.

Opens the drawer with an animation.

animateToggle

Added in API level 3
open fun animateToggle(): Unit

Deprecated: Deprecated in Java.

Toggles the drawer open and close with an animation.

close

Added in API level 3
open fun close(): Unit

Deprecated: Deprecated in Java.

Closes the drawer immediately.

getAccessibilityClassName

Added in API level 23
Deprecated in API level 17
open fun getAccessibilityClassName(): CharSequence!

Deprecated: Deprecated in Java.

getContent

Added in API level 3
open fun getContent(): View!

Deprecated: Deprecated in Java.

Returns the content of the drawer.

Return
View! The View reprenseting the content of the drawer, identified by the "content" id in XML.

getHandle

Added in API level 3
open fun getHandle(): View!

Deprecated: Deprecated in Java.

Returns the handle of the drawer.

Return
View! The View reprenseting the handle of the drawer, identified by the "handle" id in XML.

isMoving

Added in API level 3
open fun isMoving(): Boolean

Deprecated: Deprecated in Java.

Indicates whether the drawer is scrolling or flinging.

Return
Boolean True if the drawer is scroller or flinging, false otherwise.

isOpened

Added in API level 3
open fun isOpened(): Boolean

Deprecated: Deprecated in Java.

Indicates whether the drawer is currently fully opened.

Return
Boolean True if the drawer is opened, false otherwise.

lock

Added in API level 3
open fun lock(): Unit

Deprecated: Deprecated in Java.

Locks the SlidingDrawer so that touch events are ignores.

See Also

onInterceptTouchEvent

Added in API level 3
open fun onInterceptTouchEvent(event: MotionEvent!): Boolean

Deprecated: Deprecated in Java.

Parameters
ev The motion event being dispatched down the hierarchy.
Return
Boolean Return true to steal motion events from the children and have them dispatched to this ViewGroup through onTouchEvent(). The current target will receive an ACTION_CANCEL event, and no further messages will be delivered here.

onTouchEvent

Added in API level 3
open fun onTouchEvent(event: MotionEvent!): Boolean

Deprecated: Deprecated in Java.

Parameters
event MotionEvent!: The motion event.
Return
Boolean True if the event was handled, false otherwise.

open

Added in API level 3
open fun open(): Unit

Deprecated: Deprecated in Java.

Opens the drawer immediately.

setOnDrawerCloseListener

Added in API level 3
open fun setOnDrawerCloseListener(onDrawerCloseListener: SlidingDrawer.OnDrawerCloseListener!): Unit

Deprecated: Deprecated in Java.

Sets the listener that receives a notification when the drawer becomes close.

Parameters
onDrawerCloseListener SlidingDrawer.OnDrawerCloseListener!: The listener to be notified when the drawer is closed.

setOnDrawerOpenListener

Added in API level 3
open fun setOnDrawerOpenListener(onDrawerOpenListener: SlidingDrawer.OnDrawerOpenListener!): Unit

Deprecated: Deprecated in Java.

Sets the listener that receives a notification when the drawer becomes open.

Parameters
onDrawerOpenListener SlidingDrawer.OnDrawerOpenListener!: The listener to be notified when the drawer is opened.

setOnDrawerScrollListener

Added in API level 3
open fun setOnDrawerScrollListener(onDrawerScrollListener: SlidingDrawer.OnDrawerScrollListener!): Unit

Deprecated: Deprecated in Java.

Sets the listener that receives a notification when the drawer starts or ends a scroll. A fling is considered as a scroll. A fling will also trigger a drawer opened or drawer closed event.

Parameters
onDrawerScrollListener SlidingDrawer.OnDrawerScrollListener!: The listener to be notified when scrolling starts or stops.

toggle

Added in API level 3
open fun toggle(): Unit

Deprecated: Deprecated in Java.

Toggles the drawer open and close. Takes effect immediately.

unlock

Added in API level 3
open fun unlock(): Unit

Deprecated: Deprecated in Java.

Unlocks the SlidingDrawer so that touch events are processed.

See Also

Protected methods

dispatchDraw

Added in API level 3
protected open fun dispatchDraw(canvas: Canvas): Unit

Deprecated: Deprecated in Java.

Parameters
canvas Canvas: This value cannot be null.

onFinishInflate

Added in API level 3
protected open fun onFinishInflate(): Unit

Deprecated: Deprecated in Java.

onLayout

Added in API level 3
protected open fun onLayout(
    changed: Boolean,
    l: Int,
    t: Int,
    r: Int,
    b: Int
): Unit

Deprecated: Deprecated in Java.

Parameters
changed Boolean: This is a new size or position for this view
left Left position, relative to parent
top Top position, relative to parent
right Right position, relative to parent
bottom Bottom position, relative to parent

onMeasure

Added in API level 3
protected open fun onMeasure(
    widthMeasureSpec: Int,
    heightMeasureSpec: Int
): Unit

Deprecated: Deprecated in Java.

Parameters
widthMeasureSpec Int: horizontal space requirements as imposed by the parent. The requirements are encoded with android.view.View.MeasureSpec.
heightMeasureSpec Int: vertical space requirements as imposed by the parent. The requirements are encoded with android.view.View.MeasureSpec.